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

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Feb 17 1997 - 16:07:33 MET


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



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:17 MET