Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
0
Добавлен:
21.04.2026
Размер:
1.06 Кб
Скачать
#include <iostream>
#include <math.h>
#include <time.h>
#include "hist.hpp"

#ifndef M_PI
double M_PI = 3.14159265;
#endif

using namespace std;

// This function generates basic random
double gamma(){
    return (rand()+0.5)/(RAND_MAX+1.0);
}
// simulate normal distribution
int main(){
    double ksi;  // random value to study
    srand(time(NULL)); // initialize the random generator
    int num_bin = 30;
    Hist *hist = new Hist(-3.0, 3.0, num_bin); // histogram from -3 to 3 number of bins = num_bin
//    bool calc = true;
//    double twopigam, sqlog;
    for(int i=0; i<1000000; i++){
// *****************************************************

// *****************************************************
        hist->fill(ksi); // fill histogram
    }
    for(int i=0; i<hist->get_num_bin(); i++){
        cout << hist->get_bin(i) << "\t";   // get middle of bin boundary
        cout << hist->get_bin_value(i) << "\n"; // get number of counts in the bin
	}
	hist->draw(60);

    delete hist;  // destroy histogram
}

Соседние файлы в папке Моделирование процессов в физике частиц (7 сем)