# Fitting problem with TGraph and TF1 in 5.27

Hi,

Here’s a simple test case that illustrates a problem fitting in 5.27 that works fine in 5.22:

``````#! /usr/bin/env python

import ROOT
from array import array

if __name__ == "__main__":
ROOT.gROOT.SetStyle('Plain')
ROOT.gROOT.SetBatch()
yVal = array ('d', [0.95, 1, 1.1])
xVal = array ('d', [-1, 0, 1])
canvas = ROOT.TCanvas ()
graph = ROOT.TGraph ( len (xVal), xVal, yVal)
graph.SetMarkerStyle (20)
graph.SetMarkerColor (ROOT.kRed)
graph.SetMarkerSize  (1.4)
graph.SetMaximum (1.3)
graph.SetMinimum (0.7)
fun = ROOT.TF1("fun", 'pol2')
fun.FixParameter(0, 1)
graph.Fit (fun)
graph.Draw ('AP')
canvas.Print ('fit.png')``````

Running the code in 5.27b:

``````cplager@cmslpc08> fitSTC.py
****************************************
Minimizer is Linear
Chi2                      =            2
NDf                       =            0
p0                        =            1                         (fixed)
p1                        =        0.075   +/-   0.707107
p2                        =        1.025   +/-   0.707107    ``````

Running the code in 5.22:

``````cplager@cmslpc11> ./fitSTC.py

****************************************
Minimizer is Linear
Chi2                      =     6.16298e-32
NDf                       =     0
Par_0                     =     1       (fixed)
Par_1                     =     0.075   +/-     0.707107
Par_2                     =     0.025   +/-     0.707107``````

Note that the third parameter Par_2 is 0.025 in the latter case and 1.025 in the former.

Cheers,
Charles

I’ve verified that this problem exists in Cint as well, so has nothing to do with PyRoot.
I’ve posted a new copy in the Stats forum:
[url]Fitting problem with TGraph and TF1 in 5.27

Cheers,
Charles