I’m not good at English, so I’m sorry if the sentences are strange.
I got an error when I tried to execute the following source code.
{
int n=100;
double b[10];
double pi;
double cnt = 0.0;
double sum=0;
gRandom->SetSeed();
for(int a=0.0;a<n;a++){
double N=1000.0*(a+1.0);
for (int j=0;j<10.0;j++){
for (int i = 0.0; i < N; i++) {
double x = gRandom->Rndm();
double y = gRandom->Rndm();
if ((x * x + y * y) < 1.0) {
cnt +=1.0;
}
}
pi = 4.0*cnt/N;
sum+=pi;
b[j]=pi;
}
double mean=pi/10;
double sum11 = 0.0000;
for (int j = 0; j < 10; i++)sum11 += (b[j] - mean)*(b[j]-mean);
double sd = sqrt(sum11 / (10 - 1) / 10);
TGraphErrors* g = new TGraphErrors;
g->SetPointError(a, 0, sd);
g->SetPoint(a, N, mean);
g->SetMarkerStyle(20);
g->Draw("AP");
}
return 0;
}
I got the following error when using this source code. IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime8internal9EvaluateTIvEET_PNS1_15DynamicExprInfoEPN5clang11DeclContextE' unresolved while linking [cling interface function]! You are probably missing the definition of void cling::runtime::internal::EvaluateT<void>(cling::runtime::internal::DynamicExprInfo*, clang::DeclContext*)
Maybe you need to load the corresponding shared library?
It was a rudimentary mistake. I feel bad. I got another error when I corrected the pointed out part. I’m assuming you should see 200 plots on the graph, but only one.
If you have time, I would appreciate it if you could reply.
Thank you!
There was no error with this.
However, the expected graph displayed 100 points with errors, but only one point is displayed. I should have looped 100 times with the for loop, why?
Move: TGraphErrors* g = new TGraphErrors;
to right before: for(int a=0.0;a<n;a++){
and move: g->SetMarkerStyle(20); g->Draw("AP");
to right before: return 0;