Re: Data Fitting to (x,y) data points

Rene Brun (Rene.Brun@cern.ch)
Mon, 17 Feb 1997 16:07:33 +0100


Matthias Vitt wrote:
>
> Hi there,
> thankx for the help. I got another question (I hope after that one I can
> keep silent:-)..). Fitting data to a histogram is quite straight
> forward, but I cannot see how data is fitted which is stored in two
> arrays x and y that contain the x- and y-values of a pair of data
> points (f.ex. data where you measured the amplitude of a signal at
> certain, discrete temperatures, so you get datapoints like (12.354,24.5)
> and (16.7,30.25) etc.). Is there an easy way to accomplish this task?
> Any help is appreciated,

Look at the two examples in the tutorials:
http://root.cern.ch/root/html/examples/graph.C.html
and http://root.cern.ch/root/html/examples/gerrors.C.html

To fit a graph object, use TGraph::Fit (like for histograms)
gr->Fit("pol3")
will fit the graph pointed by gr with a polynomial of degree 3.

Rene Brun