Skip to content

Instantly share code, notes, and snippets.

@pn11
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pn11/6b611b6f813943175525 to your computer and use it in GitHub Desktop.
Save pn11/6b611b6f813943175525 to your computer and use it in GitHub Desktop.
中心極限定理を確かめて遊んでみた。(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