22 void exampleTKDE(
int n = 1000) {
30 TH1D * h1 =
new TH1D(
"h1",
"h1",nbin,xmin,xmax);
34 std::vector<double> data(n);
35 for (
int i = 0; i < n; ++i) {
37 data[i] = gRandom->Gaus(2,1);
41 data[i] = gRandom->Gaus(7,1.5);
47 h1->Scale(1./h1->Integral(),
"width" );
49 h1->SetTitle(
"Bi-Gaussian");
53 TF1 * f1 =
new TF1(
"f1",
"0.4*ROOT::Math::normal_pdf(x,1,2)+0.6*ROOT::Math::normal_pdf(x,1.5,7)",xmin,xmax);
54 f1->SetLineColor(kGreen+2);
59 TKDE * kde =
new TKDE(n, &data[0], xmin,xmax,
"", rho);
63 TLegend * legend =
new TLegend(0.6,0.7,0.9,0.95);
64 legend->AddEntry(f1,
"True function");
65 legend->AddEntry(kde->GetDrawnFunction(),
"TKDE");
66 legend->AddEntry(kde->GetDrawnLowerFunction(),
"TKDE - #sigma");
67 legend->AddEntry(kde->GetDrawnUpperFunction(),
"TKDE + #sigma");