#include // std::abs float mean(float data[], int n); float standard_deviation(float data[], int n); void my_pi() { int seed=34545, in, neve=0, sampling=100, jjmax=100; float x[2], xx[jjmax],yy[jjmax],zz[jjmax], mypi[sampling]; const float pi = 3.1415; gRandom->SetSeed(seed); // root command for (int jj=0; jjUniform(); // root command x[1] = gRandom->Uniform(); if( sqrt(x[0]*x[0]+x[1]*x[1]) <= 1 ) in = in + 1 ; // root command } // == mypi[kk] = 4.0 * (float(in)/float(neve)); } // =================== float my_pi = mean(mypi, sampling); float my_pi_sig = standard_deviation(mypi, sampling); xx[jj] = neve; yy[jj] = my_pi; // abs(pi - my_pi); zz[jj] = my_pi_sig; cout<Draw("AC*"); gr->Draw("ALP"); gr->SetLineWidth(1); gr->SetMarkerColor(4); gr->SetMarkerStyle(29); gr->SetTitle("MC calculation of Pi with error bar"); gr->GetXaxis()->SetTitle("MC trial events"); gr->GetYaxis()->SetTitle("estimated Pi value"); } float standard_deviation(float data[], int n) { float mean=0.0, sum_deviation=0.0; int i; for(i=0; i