How to plot a pdf

I would like to superimpose a chi-squared pdf over some data. I’ve read the section on special functions in the user’s guide, but I still don’t know how to actually plot the thing (syntax & all that)! Sorry for what may be a very basic question, but I’m new to ROOT.

Thanks!

Make a TF1 *mypdf function and add plot it with mypdf->Draw() or
add it to the list of functions of a histogram with
h->GetListOfFunctions()->Add(mypdf); It will be automatically drawn when drawing the histogram.

Rene

Here’s my attempt at plotting:

{
gROOT -> Reset();
#include “Math/SpecFunc.h”

Double_t r=4.;
Double_t x0=0.;

c1 = new TCanvas(“c1”, “chi”, 100, 10, 700, 700);
TF1 *pdf = new TF1(“pdf”, “chisquared_pdf(x, r, x0)”,0,10);
pdf -> SetLineColor(1);
pdf -> Draw();
}

And I get the following errors:

Error in TFormula::Compile: Bad numerical expression : "chisquared_pdf(x,r,x0)"
Error in TF1::TF1: function: pdf/chisquared_pdf(x, r, x0) has 0 parameters instead of 1

What does this mean?

see below:

Rene

[code]void spec() {
gSystem->Load(“libMathCore”);
Double_t r=4.;
Double_t x0=0.;

c1 = new TCanvas(“c1”, “chi”, 100, 10, 700, 700);
//TF1 *pdf = new TF1(“pdf”, “chisquared_pdf(x, r, x0)”,0,10);
TF1 *pdf = new TF1(“pdf”, “ROOT::Math::chisquared_pdf(x, [0], [1])”,0,10);
pdf->SetParameters(r,x0);
pdf -> SetLineColor(1);
pdf -> Draw();
}
[/code]

Thank you!