Last active
August 29, 2015 14:06
-
-
Save pn11/6b611b6f813943175525 to your computer and use it in GitHub Desktop.
中心極限定理を確かめて遊んでみた。(script for ROOT)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 中心極限定理を確かめて遊んでみた。(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