void histo() { int N = 50;// počet bodů double prob = 0.8;// pravdepodobnosť kroku v pravo double x[100]; FILE* file = fopen("data.txt","w"); TRandom3* rand = new TRandom3(0); TGraph* graph = new TGraph(N);// konstruktor bodového grafu s N body TH1D* hist = new TH1D("hist","Histogram krokov",100,0,50); TF1* fNorm = new TF1("fNorm","gaus",0,50); for (int k = 0; k < 1000; k++){ int a = 0; int b = 0; for (int i = 0; i < N; i++){ x[i] = rand -> Rndm(); if(x[i]>prob){ a=a+1; graph->SetPoint(i, i, a); }else{ a=a-1; b=b+1; graph->SetPoint(i, i, a); } } hist->Fill(b); fprintf(file,"%f\n",b); } hist->Draw(); fNorm->SetParameter(0,125); fNorm->SetParameter(1,(prob*100)/2); fNorm->SetParameter(2,3); fNorm->SetLineColor(4); fNorm->Draw("Same"); fclose(file); /* graph->SetTitle(""); graph->GetXaxis()->SetTitle("x"); graph->GetYaxis()->SetTitle("y"); graph->SetMarkerStyle(2); graph->Draw("AC*");// PA */ }