void f2() { static Int_t nf = 10; auto can = new TCanvas("c1", "c1", 800,500); gStyle->SetOptStat(0); auto hh = new TH1F("hh", "Averaging functions", 100,0,10); can->Draw(); hh->Draw(); TF1 * fp[nf]; TString fn; for (Int_t i=0; iSetParameters(60, 4 + gRandom->Gaus(1,0.3)); fp[i]->SetLineColor(i+2); fp[i]->SetLineWidth(1); fp[i]->Draw("same"); } Int_t npoints=20; Double_t x,y, dy = 10./npoints; auto avg = new TGraph(npoints); for (Int_t ip=0; ip < npoints; ip++) { x = dy*ip + 0.5*dy; avg->SetPoint(ip, x, 0.); } for (Int_t i=0; iGetPoint(ip, x,y); avg->SetPoint(ip, x, y + fp[i]->Eval(x)/(Double_t)nf); } } avg->SetMarkerColor(1); avg->SetMarkerSize(1); avg->Draw("* same"); hh->SetMaximum(300); can->Modified(); can->Update(); }