Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
中心極限定理を確かめて遊んでみた。(script for ROOT)
// 中心極限定理を確かめて遊んでみた。(script for ROOT)
{
int n = 10000;
int m = 2;
int nbin = 100;
double limit = 8.0;
double binwidth = 2.0*limit/double(nbin);
TH1D *h = new TH1D("h", "hist", nbin, - limit, limit);
double x;
for (int i = 0; i < n; i++){
x = 0;
for (int j = 0; j < m; j++){
x += gRandom->Uniform(0, 1);
}
h->Fill((x/double(m) - 0.5) * sqrt(m)*sqrt(12.0));
}
h->Draw();
TF1 *f = new TF1("f","gaus(0)", -10, 10);
f->SetParameters(double(n)*binwidth/sqrt(TMath::TwoPi()), 0, 1.0);
f->Draw("same");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment