void histo() { int N = 100; double tau = 1; TRandom3* random = new TRandom3(); int nBins = 10; double xmin = 0; double xmax = -1; // nebo např. 5*tau TH1D* hist = new TH1D("hist", "", nBins, xmin, xmax); // konstruktor 1-dimenzionálního histogramu (jmeno, titulek, počet binů, xmin, xmax) // je-li xmax < xmin, zvolí se automaticky hist->GetXaxis()->SetTitle("x"); for (int i = 0; i < N; i++) hist->Fill(random->Exp(tau)); // vložit jedno náhodné číslo do histogramu hist->Draw(); // přístup k hranicím a obsahu binů: printf("underflow: %f, overflow: %f\n", hist->GetBinContent(0), // nultý bin = počet čísel pod rozsahem histogramu hist->GetBinContent(nBins+1)); // nBins+1. bin: počet čísel nad rozsahem for (int i = 1; i <= nBins; i++) printf("bin [%f, %f], případů: %f\n", hist->GetBinLowEdge(i), hist->GetBinContent(i), hist->GetBinLowEdge(i+1)); }