17 #include "TMultiGraph.h" 19 #include "TObjString.h" 307 if (option.Contains(
"D"))
329 fNdim=
function->GetNdim();
330 if (!function->IsLinear()){
331 Int_t number=
function->GetNumber();
332 if (number<299 || number>310){
333 Error(
"TLinearFitter",
"Trying to fit with a nonlinear function");
346 if (option.Contains(
"D"))
440 TVirtualFitter::operator=(tlf);
465 for(Int_t i = 0; i < 1000; i++)
fVal[i] = tlf.
fVal[i];
494 for(Int_t i=0; i<
fNfixed; ++i)
532 for (Int_t i=
fNpoints; i<newsize; i++){
535 for (Int_t j=0; j<
fNdim; j++){
571 for (Int_t i=0; i<
fNdim; i++)
579 Error(
"AddPoint",
"Point can't be added, because the formula hasn't been set");
597 Error(
"AddData",
"Those points are already added");
608 fX.
Use(npoints, xncols, x);
623 for (Int_t i=xfirst; i<npoints; i++)
645 for (i=1; i<npar; i++)
647 for (i=0; i<npar; i++)
653 for (i=0; i<npar; i++)
661 if (obj->IsA() == TFormula::Class() ) {
662 TFormula *f1 = (TFormula*)(obj);
663 fVal[ii]=f1->EvalPar(x)/
e;
665 else if (obj->IsA() == TF1::Class() ) {
666 TF1 *f1 = (TF1*)(obj);
667 fVal[ii]=f1->EvalPar(x)/
e;
670 Error(
"AddToDesign",
"Basis Function %s is of an invalid type %s",obj->GetName(),obj->IsA()->GetName());
676 Error(
"AddToDesign",
"Function %s has no linear parts - maybe missing a ++ in the formula expression",
fInputFunction->GetName());
679 fVal[ii]=f->EvalPar(x)/
e;
812 Double_t temp, temp2;
829 temp2 = (
fY(i)-temp)*(
fY(i)-temp);
830 temp2 /=
fE(i)*
fE(i);
836 for (Int_t point=0; point<
fNpoints; point++){
841 for (i=1; i<npar; i++)
842 val[i] = val[i-1]*
fX(point, 0);
843 for (i=0; i<npar; i++)
850 for (i=0; i<npar; i++)
854 TFormula *f1 = (TFormula*)(
fFunctions.UncheckedAt(j));
860 temp2 = (
fY(point)-temp)*(
fY(point)-temp);
861 temp2 /=
fE(point)*
fE(point);
889 Error(
"TLinearFitter::Eval",
"The formula hasn't been set");
930 for (ii=0; ii<i; ii++)
957 Error(
"Eval",
"Matrix inversion failed");
994 for (ii=0; ii<i; ii++){
1015 Error(
"FixParameter",
"no value available to fix the parameter");
1019 Error(
"FixParameter",
"illegal parameter value");
1023 Error(
"FixParameter",
"no free parameters left");
1038 Error(
"FixParameter",
"illegal parameter value");
1042 Error(
"FixParameter",
"no free parameters left");
1060 Error(
"ReleaseParameter",
"illegal parameter value");
1064 Warning(
"ReleaseParameter",
"This parameter is not fixed\n");
1118 for (Int_t ipoint=0; ipoint<n; ipoint++){
1125 sum_vector[irow]+=
fParCovar(irow,icol)*grad[icol];
1129 c+=grad[i]*sum_vector[i];
1131 ci[ipoint]=c*t*chidf;
1135 delete [] sum_vector;
1162 Error(
"GetConfidenceIntervals",
"The case of fitting not with a TFormula is not yet implemented");
1168 if (obj->InheritsFrom(TGraph::Class())) {
1169 TGraph *gr = (TGraph*)obj;
1171 Error(
"GetConfidenceIntervals",
"A TGraphErrors should be passed instead of a graph");
1174 if (fObjectFit->InheritsFrom(TGraph2D::Class())){
1175 Error(
"GetConfidenceIntervals",
"A TGraph2DErrors should be passed instead of a graph");
1178 if (fObjectFit->InheritsFrom(TH1::Class())){
1179 if (((TH1*)(fObjectFit))->GetDimension()>1){
1180 Error(
"GetConfidenceIntervals",
"A TGraph2DErrors or a TH23 should be passed instead of a graph");
1186 for (Int_t i=0; i<gr->GetN(); i++)
1187 gr->SetPoint(i, gr->GetX()[i],
fInputFunction->Eval(gr->GetX()[i]));
1191 else if (obj->InheritsFrom(TGraph2D::Class())) {
1192 TGraph2D *gr2 = (TGraph2D*)obj;
1194 Error(
"GetConfidenceIntervals",
"A TGraph2DErrors should be passed instead of a TGraph2D");
1197 if (fObjectFit->InheritsFrom(TGraph::Class())){
1198 Error(
"GetConfidenceIntervals",
"A TGraphErrors should be passed instead of a TGraph2D");
1201 if (fObjectFit->InheritsFrom(TH1::Class())){
1202 if (((TH1*)(fObjectFit))->GetDimension()==1){
1203 Error(
"GetConfidenceIntervals",
"A TGraphErrors or a TH1 should be passed instead of a graph");
1208 Int_t np = gr2->GetN();
1211 Double_t *
x = gr2->GetX();
1212 Double_t *
y = gr2->GetY();
1216 for (Int_t ipoint=0; ipoint<np; ipoint++){
1224 sum_vector[irow]+=
fParCovar(irow, icol)*grad[icol];
1227 c+=grad[i]*sum_vector[i];
1229 gr2->SetPoint(ipoint, xy[0], xy[1],
fInputFunction->EvalPar(xy));
1230 gr2->GetEZ()[ipoint]=c*t*chidf;
1233 delete [] sum_vector;
1237 else if (obj->InheritsFrom(TH1::Class())) {
1238 if (fObjectFit->InheritsFrom(TGraph::Class())){
1239 if (((TH1*)obj)->GetDimension()>1){
1240 Error(
"GetConfidenceIntervals",
"Fitted graph and passed histogram have different number of dimensions");
1244 if (fObjectFit->InheritsFrom(TGraph2D::Class())){
1245 if (((TH1*)obj)->GetDimension()!=2){
1246 Error(
"GetConfidenceIntervals",
"Fitted graph and passed histogram have different number of dimensions");
1250 if (fObjectFit->InheritsFrom(TH1::Class())){
1251 if (((TH1*)(fObjectFit))->GetDimension()!=((TH1*)(obj))->GetDimension()){
1252 Error(
"GetConfidenceIntervals",
"Fitted and passed histograms have different number of dimensions");
1258 TH1 *hfit = (TH1*)obj;
1262 Int_t hxfirst = hfit->GetXaxis()->GetFirst();
1263 Int_t hxlast = hfit->GetXaxis()->GetLast();
1264 Int_t hyfirst = hfit->GetYaxis()->GetFirst();
1265 Int_t hylast = hfit->GetYaxis()->GetLast();
1266 Int_t hzfirst = hfit->GetZaxis()->GetFirst();
1267 Int_t hzlast = hfit->GetZaxis()->GetLast();
1269 TAxis *xaxis = hfit->GetXaxis();
1270 TAxis *yaxis = hfit->GetYaxis();
1271 TAxis *zaxis = hfit->GetZaxis();
1275 for (Int_t binz=hzfirst; binz<=hzlast; binz++){
1276 x[2]=zaxis->GetBinCenter(binz);
1277 for (Int_t biny=hyfirst; biny<=hylast; biny++) {
1278 x[1]=yaxis->GetBinCenter(biny);
1279 for (Int_t binx=hxfirst; binx<=hxlast; binx++) {
1280 x[0]=xaxis->GetBinCenter(binx);
1286 sum_vector[irow]+=
fParCovar(irow, icol)*grad[icol];
1289 c+=grad[i]*sum_vector[i];
1291 hfit->SetBinContent(binx, biny, binz,
fInputFunction->EvalPar(x));
1292 hfit->SetBinError(binx, biny, binz, c*t*chidf);
1297 delete [] sum_vector;
1300 Error(
"GetConfidenceIntervals",
"This object type is not supported");
1367 Error(
"GetParError",
"illegal value of parameter");
1385 Error(
"GetParError",
"illegal value of parameter");
1399 Error(
"GetParError",
"illegal value of parameter");
1413 Error(
"GetParTValue",
"illegal value of parameter");
1427 Error(
"GetParSignificance",
"illegal value of parameter");
1441 Error(
"GetFitSample",
"there is no fit sample in ordinary least-squares fit");
1445 bits.SetBitNumber(i,
fFitsample.TestBitNumber(i));
1454 if (!list)
return -1;
1458 if (!lfit->InheritsFrom(TLinearFitter::Class())) {
1459 Error(
"Add",
"Attempt to add object of class: %s to a %s",lfit->ClassName(),this->ClassName());
1500 for (
int i=0; i<size; i++)
1534 Int_t size = 0, special = 0;
1545 fstring = (
char *)strstr(
fFormula,
"hyp");
1549 sscanf(fstring,
"%d", &size);
1558 sstring = sstring.ReplaceAll(
"++", 2,
"|", 1);
1559 TString replaceformula;
1563 TObjArray *oa = sstring.Tokenize(
"|");
1577 char replacement[14];
1578 for (i=0; i<
fNdim; i++){
1579 snprintf(pattern,
sizeof(pattern),
"x%d", i);
1580 snprintf(replacement,
sizeof(replacement),
"x[%d]", i);
1581 sstring = sstring.ReplaceAll(pattern, Int_t(i/10)+2, replacement, Int_t(i/10)+4);
1585 oa = sstring.Tokenize(
"|");
1587 replaceformula = ((TObjString *)oa->UncheckedAt(i))->GetString();
1589 TFormula * f =
nullptr;
1595 f =
new TFormula(
"f", replaceformula.Data());
1597 R__LOCKGUARD(gROOTMutex);
1602 Error(
"TLinearFitter",
"f_linear not allocated");
1605 special=f->GetNumber();
1609 if ((
fNfunctions==1)&&(special>299)&&(special<310)){
1641 for (i=0; i<size; i++)
1653 Int_t special, size;
1661 if ((special>299)&&(special<310)){
1696 for (Int_t i=0; i<size; i++)
1700 if (function->InheritsFrom(TF1::Class())){
1703 ((TF1*)
function)->GetParLimits(i,al,bl);
1704 if (al*bl !=0 && al >= bl) {
1735 if (!strcmp(command,
"FitGraph")){
1739 if (!strcmp(command,
"FitGraph2D")){
1743 if (!strcmp(command,
"FitMultiGraph")){
1761 printf(
"Fitting results:\nParameters:\nNO.\t\tVALUE\t\tERROR\n");
1766 printf(
"Fitting results:\nParameters:\nNO.\t\tVALUE\n");
1768 printf(
"%d\t%e\n", i,
fParams(i));
1780 TGraph *grr=(TGraph*)GetObjectFit();
1781 TF1 *f1=(TF1*)GetUserFunc();
1782 Foption_t fitOption=GetFitOption();
1785 Double_t *
x=grr->GetX();
1786 Double_t *
y=grr->GetY();
1789 Int_t fitResult = 0;
1794 if (fitOption.Robust){
1799 Int_t n=grr->GetN();
1800 for (Int_t i=0; i<n; i++){
1801 if (!f1->IsInside(&x[i]))
continue;
1802 e=grr->GetErrorY(i);
1803 if (e<0 || fitOption.W1)
1808 if (fitOption.Robust){
1816 if (!fitOption.Nochisq){
1817 Double_t temp, temp2, sumtotal=0;
1818 for (Int_t i=0; i<n; i++){
1819 if (!f1->IsInside(&x[i]))
continue;
1820 temp=f1->Eval(x[i]);
1821 temp2=(y[i]-temp)*(y[i]-temp);
1822 e=grr->GetErrorY(i);
1823 if (e<0 || fitOption.W1)
1843 TGraph2D *gr=(TGraph2D*)GetObjectFit();
1844 TF2 *f2=(TF2*)GetUserFunc();
1846 Foption_t fitOption=GetFitOption();
1847 Int_t n = gr->GetN();
1848 Double_t *gx = gr->GetX();
1849 Double_t *gy = gr->GetY();
1850 Double_t *gz = gr->GetZ();
1857 if (fitOption.Robust){
1862 for (Int_t bin=0;bin<n;bin++) {
1865 if (!f2->IsInside(x)) {
1869 e=gr->GetErrorZ(bin);
1870 if (e<0 || fitOption.W1)
1875 if (fitOption.Robust){
1882 if (!fitOption.Nochisq){
1884 Double_t temp, temp2, sumtotal=0;
1885 for (Int_t bin=0; bin<n; bin++){
1888 if (!f2->IsInside(x)) {
1893 temp=f2->Eval(x[0], x[1]);
1894 temp2=(z-temp)*(z-temp);
1895 e=gr->GetErrorZ(bin);
1896 if (e<0 || fitOption.W1)
1917 TVirtualFitter *grFitter = TVirtualFitter::GetFitter();
1918 TMultiGraph *mg = (TMultiGraph*)grFitter->GetObjectFit();
1919 TF1 *f1 = (TF1*)grFitter->GetUserFunc();
1920 Foption_t fitOption = grFitter->GetFitOption();
1924 if (fitOption.Robust){
1931 TIter next(mg->GetListOfGraphs());
1932 while ((gr = (TGraph*) next())) {
1936 for (i=0; i<n; i++){
1937 if (!f1->IsInside(&gx[i]))
continue;
1939 if (e<0 || fitOption.W1)
1945 if (fitOption.Robust){
1953 if (!fitOption.Nochisq){
1954 Double_t temp, temp2, sumtotal=0;
1956 while((gr = (TGraph*)next())) {
1960 for (i=0; i<n; i++){
1961 if (!f1->IsInside(&gx[i]))
continue;
1962 temp=f1->Eval(gx[i]);
1963 temp2=(gy[i]-temp)*(gy[i]-temp);
1965 if (e<0 || fitOption.W1)
1989 Int_t bin,binx,biny,binz;
1992 TH1 *hfit = (TH1*)GetObjectFit();
1993 TF1 *f1 = (TF1*)GetUserFunc();
1995 Foption_t fitOption = GetFitOption();
2000 Int_t hxfirst = GetXfirst();
2001 Int_t hxlast = GetXlast();
2002 Int_t hyfirst = GetYfirst();
2003 Int_t hylast = GetYlast();
2004 Int_t hzfirst = GetZfirst();
2005 Int_t hzlast = GetZlast();
2006 TAxis *xaxis = hfit->GetXaxis();
2007 TAxis *yaxis = hfit->GetYaxis();
2008 TAxis *zaxis = hfit->GetZaxis();
2010 for (binz=hzfirst;binz<=hzlast;binz++) {
2011 x[2] = zaxis->GetBinCenter(binz);
2012 for (biny=hyfirst;biny<=hylast;biny++) {
2013 x[1] = yaxis->GetBinCenter(biny);
2014 for (binx=hxfirst;binx<=hxlast;binx++) {
2015 x[0] = xaxis->GetBinCenter(binx);
2016 if (!f1->IsInside(x))
continue;
2017 bin = hfit->GetBin(binx,biny,binz);
2018 cu = hfit->GetBinContent(bin);
2019 if (f1->GetNdim() < hfit->GetDimension()) {
2020 if (hfit->GetDimension() > 2) cu = x[2];
2024 if (fitOption.W1==1 && cu == 0)
continue;
2027 eu = hfit->GetBinError(bin);
2028 if (eu <= 0)
continue;
2038 if (!fitOption.Nochisq){
2039 Double_t temp, temp2, sumtotal=0;
2040 for (binz=hzfirst;binz<=hzlast;binz++) {
2041 x[2] = zaxis->GetBinCenter(binz);
2042 for (biny=hyfirst;biny<=hylast;biny++) {
2043 x[1] = yaxis->GetBinCenter(biny);
2044 for (binx=hxfirst;binx<=hxlast;binx++) {
2045 x[0] = xaxis->GetBinCenter(binx);
2046 if (!f1->IsInside(x))
continue;
2047 bin = hfit->GetBin(binx,biny,binz);
2048 cu = hfit->GetBinContent(bin);
2051 if (fitOption.W1==1 && cu == 0)
continue;
2054 eu = hfit->GetBinError(bin);
2055 if (eu <= 0)
continue;
2057 temp=f1->EvalPar(x);
2058 temp2=(cu-temp)*(cu-temp);
2074 void TLinearFitter::Streamer(TBuffer &R__b)
2076 if (R__b.IsReading()) {
2078 R__b.ReadClassBuffer(TLinearFitter::Class(),
this);
2091 R__b.WriteClassBuffer(TLinearFitter::Class(),
this);
2107 Double_t kEps = 1
e-13;
2109 Int_t i, j, maxind=0, k, k1 = 500;
2114 Error(
"TLinearFitter::EvalRobust",
"The formula hasn't been set");
2119 Double_t *bestchi2 =
new Double_t[nbest];
2120 for (i=0; i<nbest; i++)
2125 if (h>0.000001 && h<1 && fNpoints*h > hdef)
2129 if (h>0) Warning(
"Fitting:",
"illegal value of H, default is taken, h = %3.2f",
double(hdef)/
fNpoints);
2137 Int_t *index =
new Int_t[
fNpoints];
2138 Double_t *residuals =
new Double_t[
fNpoints];
2145 for (k = 0; k < k1; k++) {
2147 chi2 =
CStep(1,
fH, residuals,index, index, -1, -1);
2148 chi2 =
CStep(2,
fH, residuals,index, index, -1, -1);
2150 if (chi2 < bestchi2[maxind]) {
2151 bestchi2[maxind] = chi2;
2153 cstock(i, maxind) =
fParams(i);
2158 Int_t *bestindex =
new Int_t[
fH];
2159 Double_t currentbest;
2160 for (i=0; i<nbest; i++) {
2164 while (chi2 > kEps) {
2165 chi2 =
CStep(2,
fH, residuals,index, index, -1, -1);
2166 if (TMath::Abs(chi2 - bestchi2[i]) < kEps)
2172 if (chi2 <= currentbest + kEps) {
2173 for (j=0; j<
fH; j++){
2174 bestindex[j]=index[j];
2183 fParams(j) = cstock(j, maxind);
2185 for (j=0; j<
fH; j++){
2195 delete [] bestindex;
2196 delete [] residuals;
2205 Int_t nsub =
Partition(nmini, indsubdat);
2208 Int_t sum = TMath::Min(nmini*5,
fNpoints);
2210 Int_t *subdat =
new Int_t[sum];
2211 RDraw(subdat, indsubdat);
2214 Int_t *beststock =
new Int_t[nbest];
2216 Int_t i_end = indsubdat[0];
2217 Int_t k2 = Int_t(k1/nsub);
2218 for (Int_t kgroup = 0; kgroup < nsub; kgroup++) {
2220 hsub = Int_t(
fH * indsubdat[kgroup]/
fNpoints);
2221 for (i=0; i<nbest; i++)
2223 for (k=0; k<k2; k++) {
2225 chi2 =
CStep(1, hsub, residuals, index, subdat, i_start, i_end);
2226 chi2 =
CStep(2, hsub, residuals, index, subdat, i_start, i_end);
2228 if (chi2 < bestchi2[maxind]){
2230 cstockbig(i, nbest*kgroup + maxind) =
fParams(i);
2231 bestchi2[maxind] = chi2;
2234 if (kgroup != nsub - 1){
2235 i_start += indsubdat[kgroup];
2236 i_end += indsubdat[kgroup+1];
2240 for (i=0; i<nbest; i++)
2244 for (k=0; k<nbest*5; k++) {
2247 chi2 =
CStep(1, hsub2, residuals, index, subdat, 0, sum);
2248 chi2 =
CStep(2, hsub2, residuals, index, subdat, 0, sum);
2250 if (chi2 < bestchi2[maxind]){
2251 beststock[maxind] = k;
2252 bestchi2[maxind] = chi2;
2257 for (k=0; k<nbest; k++) {
2259 fParams(i) = cstockbig(i, beststock[k]);
2260 chi2 =
CStep(1,
fH, residuals, index, index, -1, -1);
2261 chi2 =
CStep(2,
fH, residuals, index, index, -1, -1);
2267 fParams(i)=cstockbig(i, beststock[maxind]);
2270 while (chi2 > kEps) {
2271 chi2 =
CStep(2,
fH, residuals, index, index, -1, -1);
2272 if (TMath::Abs(chi2 - bestchi2[maxind]) < kEps)
2275 bestchi2[maxind] = chi2;
2279 for (j=0; j<
fH; j++)
2288 delete [] beststock;
2290 delete [] residuals;
2303 Bool_t repeat=kFALSE;
2306 for(i=0; i<ntotal; i++)
2307 index[i] = ntotal+1;
2312 num=Int_t(r.
Uniform(0, 1)*(ntotal-1));
2314 for(j=0; j<=i-1; j++) {
2339 while (!ok && (nindex < h)) {
2342 num=Int_t(r.
Uniform(0,1)*(ntotal-1));
2344 for(i=0; i<nindex; i++) {
2350 }
while(repeat==kTRUE);
2352 index[nindex] = num;
2363 Double_t
TLinearFitter::CStep(Int_t step, Int_t h, Double_t *residuals, Int_t *index, Int_t *subdat, Int_t start, Int_t end)
2367 Int_t i, j, itemp, n;
2373 for (i=0; i<n; i++) {
2375 itemp = subdat[start+i];
2384 for (j=1; j<npar; j++)
2385 val[j] = val[j-1]*
fX(itemp, 0);
2386 for (j=0; j<npar; j++)
2392 for (j=0; j<npar; j++)
2403 residuals[i] = (
fY(itemp) - func)*(
fY(itemp) - func)/(
fE(i)*
fE(i));
2417 for (j=1; j<npar; j++)
2418 val[j] = val[j-1]*
fX(i, 0);
2419 for (j=0; j<npar; j++)
2425 for (j=0; j<npar; j++)
2435 residuals[i] = (
fY(i) - func)*(
fY(i) - func)/(
fE(i)*
fE(i));
2449 if (step==1)
return 0;
2454 for (i=0; i<h; i++) {
2455 itemp = subdat[start+index[i]];
2464 for (j=1; j<npar; j++)
2465 val[j] = val[j-1]*
fX(itemp, 0);
2466 for (j=0; j<npar; j++)
2472 for (j=0; j<npar; j++)
2482 sum+=(
fY(itemp)-func)*(
fY(itemp)-func)/(
fE(itemp)*
fE(itemp));
2485 for (i=0; i<h; i++) {
2494 for (j=1; j<npar; j++)
2495 val[j] = val[j-1]*
fX(index[i], 0);
2496 for (j=0; j<npar; j++)
2503 for (j=0; j<npar; j++)
2515 sum+=(
fY(index[i])-func)*(
fY(index[i])-func)/(
fE(index[i])*
fE(index[i]));
2549 Error(
"Linf",
"Matrix inversion failed");
2570 indsubdat[1]=Int_t(
fNpoints*0.5)+1;
2572 indsubdat[0]=indsubdat[1]=Int_t(
fNpoints/2);
2578 indsubdat[0]=indsubdat[1]=indsubdat[2]=Int_t(
fNpoints/3);
2583 else indsubdat[2]=Int_t(
fNpoints/3)+1;
2589 if (
fNpoints%4==0) indsubdat[0]=indsubdat[1]=indsubdat[2]=indsubdat[3]=Int_t(
fNpoints/4);
2602 for(Int_t i=0; i<5; i++)
2621 for (i=0; i<5; i++) {
2622 if (indsubdat[i]!=0)
2626 for (k=1; k<=ngroup; k++) {
2627 for (m=1; m<=indsubdat[k-1]; m++) {
2633 subdat[jndex-1] = nrand + jndex - 2;
2634 for (i=1; i<=jndex-1; i++) {
2635 if(subdat[i-1] > nrand+i-2) {
2636 for(j=jndex; j>=i+1; j--) {
2637 subdat[j-1] = subdat[j-2];
2639 subdat[i-1] = nrand+i-2;
virtual void GetAtbVector(TVectorD &v)
Get the Atb vector - a vector, used for internal computations.
virtual void GetErrors(TVectorD &vpar)
Returns parameter errors.
virtual void StoreData(Bool_t store)
void RDraw(Int_t *subdat, Int_t *indsubdat)
Draws ngroup nonoverlapping subdatasets out of a dataset of size n such that the selected case number...
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1)
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
Long64_t LocMax(Long64_t n, const T *a)
Return index of array with the maximum element.
virtual void FixParameter(Int_t ipar)
Fixes paramter #ipar at its current value.
virtual TMatrixTBase< Element > & Zero()
Set matrix elements to zero.
The Linear Fitter - For fitting functions that are LINEAR IN PARAMETERS.
virtual const Element * GetMatrixArray() const
Random number generator class based on the maximally quidistributed combined Tausworthe generator by ...
virtual void AddTempMatrices()
Double_t StudentQuantile(Double_t p, Double_t ndf, Bool_t lower_tail=kTRUE)
Computes quantiles of the Student's t-distribution 1st argument is the probability, at which the quantile is computed 2nd argument - the number of degrees of freedom of the Student distribution When the 3rd argument lower_tail is kTRUE (default)- the algorithm returns such x0, that.
TObjArray fFunctions
map of basis functions and formula
virtual void GetConfidenceIntervals(Int_t n, Int_t ndim, const Double_t *x, Double_t *ci, Double_t cl=0.95)
Computes point-by-point confidence intervals for the fitted function Parameters: n - number of points...
virtual void ClearPoints()
To be used when different sets of points are fitted with the same formula.
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
To use in TGraph::Fit and TH1::Fit().
Int_t Graph2DLinearFitter(Double_t h)
Minimisation function for a TGraph2D.
static std::map< TString, TFormula * > fgFormulaMap
virtual void GetDesignMatrix(TMatrixD &matr)
Returns the internal design matrix.
virtual const Element * GetMatrixArray() const
Int_t Partition(Int_t nmini, Int_t *indsubdat)
divides the elements into approximately equal subgroups number of elements in each subgroup is stored...
virtual Double_t * GetCovarianceMatrix() const
Returns covariance matrix.
virtual const char * GetParName(Int_t ipar) const
Returns name of parameter #ipar.
virtual void Clear(Option_t *="")
TFormula * fInputFunction
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1)
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
you should not use this method at all Int_t y
Double_t StudentI(Double_t T, Double_t ndf)
Calculates the cumulative distribution function of Student's t-distribution second parameter stands f...
TVectorT< Element > & Use(Int_t lwb, Int_t upb, Element *data)
Use the array data to fill the vector lwb..upb].
virtual void PrintResults(Int_t level, Double_t amin=0) const
Level = 3 (to be consistent with minuit) prints parameters and parameter errors.
This is the base class for the ROOT Random number generators.
virtual void GetFitSample(TBits &bits)
For robust lts fitting, returns the sample, on which the best fit was based.
Double_t CStep(Int_t step, Int_t h, Double_t *residuals, Int_t *index, Int_t *subdat, Int_t start, Int_t end)
The CStep procedure, as described in the article.
virtual void Clear(Option_t *option="")
Clears everything. Used in TH1::Fit and TGraph::Fit().
Bool_t Invert(TMatrixDSym &inv)
For a symmetric matrix A(m,m), its inverse A_inv(m,m) is returned .
void Clear(Option_t *="")
TMatrixTRow< Double_t > TMatrixDRow
virtual void Chisquare()
Calculates the chisquare.
void CreateSubset(Int_t ntotal, Int_t h, Int_t *index)
Creates a p-subset to start ntotal - total number of points from which the subset is chosen...
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t Int_t m
Element * GetMatrixArray()
virtual Double_t GetParTValue(Int_t ipar)
Returns the t-value for parameter #ipar.
void AddToDesign(Double_t *x, Double_t y, Double_t e)
Add a point to the AtA matrix and to the Atb vector.
Cholesky Decomposition class.
Int_t HistLinearFitter()
Minimization function for H1s using a Chisquare method.
virtual Double_t GetParameter(Int_t ipar) const
virtual Bool_t Solve(TVectorD &b)
Solve equations Ax=b assuming A has been factored by Cholesky.
virtual Double_t GetParSignificance(Int_t ipar)
Returns the significance of parameter #ipar.
Int_t MultiGraphLinearFitter(Double_t h)
Minimisation function for a TMultiGraph.
virtual Int_t EvalRobust(Double_t h=-1)
Finds the parameters of the fitted function in case data contains outliers.
virtual Double_t GetChisquare()
Get the Chisquare.
TVectorT< Element > & Zero()
Set vector elements to zero.
Int_t GraphLinearFitter(Double_t h)
Used in TGraph::Fit().
virtual void ReleaseParameter(Int_t ipar)
Releases parameter #ipar.
TLinearFitter()
default c-tor, input data is stored If you don't want to store the input data, run the function Store...
TMatrixD fX
temporary variable used for num.stability
Int_t GetNoElements() const
virtual void SetBasisFunctions(TObjArray *functions)
set the basis functions in case the fitting function is not set directly The TLinearFitter will manag...
* x
Deprecated and error prone model selection interface.
virtual Int_t Eval()
Perform the fit and evaluate the parameters Returns 0 if the fit is ok, 1 if there are errors...
TMatrixDSym fDesignTemp2
temporary matrix, used for num.stability
Int_t NonZeros() const
Compute the number of elements != 0.0.
virtual void Add(TLinearFitter *tlf)
Add another linear fitter to this linear fitter.
virtual ~TLinearFitter()
Linear fitter cleanup.
virtual void Clear(Option_t *="")
TLinearFitter & operator=(const TLinearFitter &tlf)
Assignment operator.
virtual void GetParameters(TVectorD &vpar)
Returns parameter values.
virtual Double_t GetParError(Int_t ipar) const
Returns the error of parameter #ipar.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
virtual void AssignData(Int_t npoints, Int_t xncols, Double_t *x, Double_t *y, Double_t *e=0)
This function is to use when you already have all the data in arrays and don't want to copy them into...
virtual void SetFormula(const char *formula)
Additive parts should be separated by "++".
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
virtual void SetDim(Int_t n)
set the number of dimensions
void ComputeTValues()
Computes parameters' t-values and significance.
TMatrixT< Element > & Use(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Element *data)
Use the array data to fill the matrix ([row_lwb..row_upb] x [col_lwb..col_upb])
you should not use this method at all Int_t Int_t z
Element KOrdStat(Size n, const Element *a, Size k, Size *work=0)
Returns k_th order statistic of the array a of size n (k_th smallest element out of n elements)...
virtual Bool_t UpdateMatrix()
Update the design matrix after the formula has been changed.
Double_t Sqrt(Double_t x)
Long64_t LocMin(Long64_t n, const T *a)
Return index of array with the minimum element.
TVectorD fAtbTemp2
temporary vector, used for num.stability
virtual Int_t Merge(TCollection *list)
Merge objects in list.
T MinElement(Long64_t n, const T *a)
Return minimum of array a of length n.
virtual void AddPoint(Double_t *x, Double_t y, Double_t e=1)
Adds 1 point to the fitter.