Size of TF1::GetParErrors()

Dear all,

I have quick question related to the size of the array/vector returned by TF1::GetParErrors().

In order to demonstrate what I mean, here is some example code:

[code]from ROOT import *

c1 = TCanvas(“c1”,“c1”,600,400);

create/fill draw h1

gStyle.SetOptStat(kFALSE);
h1 = TH1F(“h1”,“Superimposing two histograms with different scales”,100,-3,3);

for i in range(0,10000):
h1.Fill(gRandom.Gaus(0,1));
h1.Draw();

h1.Fit(‘gaus’, “Q0”, “ah”, -3, 3)
fit = h1.GetFunction(‘gaus’)
fit.Draw(‘same’)
c1.Update();
print ‘Number of parameter errors’, len(fit.GetParErrors())

errors = fit.GetParErrors()
for i in range(0, 10):
print ‘Error No. %d:’ % i, errors[i]

[/code]

The output of this is:

Number of parameter errors 2147483647 Error No. 0: 2.99964769364 Error No. 1: 0.00995766345455 Error No. 2: 0.00722748152275 Error No. 3: 1.63041663128e-322 Error No. 4: 0.0 Error No. 5: 0.0 Error No. 6: 0.0 Error No. 7: 1.63041663128e-322 Error No. 8: 0.0 Error No. 9: 0.0

The size of the error vector is therefore unlimited.
Since I am working with different fit functions which I don’t know a priory and would like to store only the relevant errors, is it safe to use:

for i in range(0, fit.GetNumberFreeParameters()-1): print 'Error No. %d:' % i, errors[i]
?
To rephrase it: are the free parameters always stored at the beginning of the list with no exceptions?

Cheers,
Luke

Hi,

the result of GetParErrors() is unsized, since the C++ interface declares nothing more than a Double_t* so no size information is available there. You can fix up the result with SetSize(), and yes I think that the number of free parameters is the proper size (in any case, I can’t see why the proper errors would not be consecutive as the first elements in the array; doing anything else would make the code unusable in C++ as well).

Cheers,
Wim