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

// This function generates basic random
double gamma(){
	return (rand()+0.5)/(RAND_MAX+1.0);
}
// simulate 1/2*exp(-2x) + 3/2*exp(-3x) + exp(-4x)
int main(){
	double ksi;  // random value
	double a[]={-2., -3., -4.};
	double pa[]={1.., 1., 1.};
	int k; // random index of a
	srand(time(NULL)); // initialize the random generator
// discrete random from array
	int num_bin = 20;
	Hist *hist = new Hist(0, 2, num_bin);
	for( int i=0; i<4000000; i++ ){

// ****************************************************

// here simulation code

// ****************************************************

		hist->fill(ksi); // fill histogramm
	}
	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 histogramm

	getchar();  // wait "Enter" to close window

}
Соседние файлы в папке m2