More fit parameters

Tadeusz Pytlos (pytlos@fizwe5.fic.uni.lodz.pl)
Fri, 8 May 1998 16:07:26 +0200 (CEST)


This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.

--1556251094-873584403-894636441=:6542
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hello Rooters,
I have a few problems linking with fiting of histogram.
1) I'm trying to solve such equation
myhist=integral(0,infinity) fun1(dN)*fun2() d(dN),
where function fun2() I don't know, so I treat it as parameters
to estimate par[dN]. Of course, intergral I replace by sum(0,dN).
The problem is that there are only maximum 10 parameters to fit!
It's too less for my purposes. Is it possible to implement more?
Or is there any better possibility to solve my problem?
Can I use TMinuit for such problem? I will be grateful
for any ideas.
I include my macro and root file with histogram. Myhist is red and
right side of equation is black.

2) Is possible to implement such functions like Factorial
and Binomial in future ROOT?
3) I don't understand why my macro didn't stop, but I have to use
getchar(). What clears my canvas?
4) I went about it, but I want to mention. I had problems with
Double_t fitf(Int_t *k, Double_t *par). Is fit function only designed
for Double_t?
Thank you in advance.
Best wishes,
Tadeusz Pytlos

---------------prob.C---------------------------

Double_t Factorial(Int_t f)
{
Int_t b;
Double_t x;
if(f==0)
{
x=1.0;
return x;
}
x=1;
b=0;
do
{
b=b+1;
x=x*b;
}while(b!=f);
return x;
}

Double_t fitf(Double_t *x, Double_t *par)
{
Int_t dN;
Int_t m=12;
Float_t At=m*156.25;
Float_t Ad=3.24;
Int_t k=x[0];
Double_t mm=Factorial(m);
Double_t kk=Factorial(k);
Double_t mk=Factorial(m-k);
Double_t Binomial=mm/kk/mk;
Float_t a0=1-Ad/At;
Double_t a1,a2,a3,fun1,wart;

wart=0;
for(dN=0;dN<10;dN++)
{
a1=1-TMath::Exp(-dN*a0);
a2=TMath::Power(a1,k);
a3=TMath::Exp(-dN*(m-k)*a0);
fun1=Binomial*a2*a3;
wart=wart+fun1*par[dN];
}
Double_t fitval=wart;
return fitval;
}

void prob()
{
//////////////////////////////////////////////////////////
// This file has been automatically generated
// (Mon Nov 24 12:46:19 1997 by ROOT version 1.03/07)
// from TTree kas/BASKET
// found on file: dst00459.root
//////////////////////////////////////////////////////////

//Reset ROOT and connect tree file
gROOT->Reset();
TFile hfile("prob.root");
page = new TCanvas("page","Probability",0,0,500,700);
page->SetFillColor(10);
page->Divide(1,1);

Int_t kpad,ans;
char padname[20];

kpad=1;
sprintf(padname,"page_%d",kpad);
TPad *pad = (TPad*)page->GetPrimitive(padname);
pad->cd();
pad->SetGrid();
pad->SetLogy();
pad->GetFrame()->SetFillColor(42);
pad->GetFrame()->SetBorderMode(-1);
pad->GetFrame()->SetBorderSize(5);
pad->Draw();

char hname[20];
TH1 *h;

sprintf(hname,"h%d",kpad);
h=(TH1F*)hfile.Get(hname);
h.SetLineWidth(2);
h.SetLineStyle(1);
h.SetLineColor(1);
h.SetXTitle("k");
h.SetYTitle("N");
h.SetMinimum(0.001);
h.Draw();

TF1 *func=new TF1("func",fitf,0,30,10);
func->SetParameters(0,0,0,0,0,0,0,0,0,0);
h.SetLineColor(2);
h->Fit("func","r");

page.Update();
TPostScript mps("prob.eps",113);
page.Draw();
mps.Close();

ans=getchar();
page->cd();

}

--
Tadeusz Pytlos        
mailto:pytlos@fizwe5.fic.uni.lodz.pl 
Lodz, Poland                                                 

--1556251094-873584403-894636441=:6542 Content-Type: APPLICATION/octet-stream; name="prob.root" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.LNX.3.96.980508160721.6542B@fizwe5.fic.uni.lodz.pl> Content-Description:

cm9vdAAATiQAAABAAAACgwAAAjUAAABOAAAAAQAAAGgEAAAAAQAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAIYAAQAAAEINTyKaAEQAAQAAAEAAAAAA BVRGaWxlCGRlcC5yb290GlJPT1QgZmlsZXMgd2l0aCBoaXN0b2dyYW1zCGRl cC5yb290GlJPT1QgZmlsZXMgd2l0aCBoaXN0b2dyYW1zAAENTyKaDVCY1gAA AHwAAABoAAAAQAAAAAAAAAG5AAAA8wABAAABkw1QIvQANAABAAAAxgAAAEAE VEgxUwJoMRFEaXN0cmlidXRpb24gb2Yga0NTCLYAAJMBAGNgZIBAIGBmYOBg yjAUdMksLinKTCotyczPU8hPU8iGKgErY34JYdk3gLQw8AN1gcXB2hlYKxIr MosZsxmYGBgY/4Fl7KwXX+eyVb7OZfP1UD9IF4gNVMoLxAyOASASCaCaVgk2 zY8I08B6oG5CAFTTqkCmMZBtGAPzC0dGPQkQC512uLfSAUx/2bwBRB/pesBg e+bMWRAbAcDGMoDCjKH+v8hnYUbuCJZ7jC0MoQzCQEfBZBkAAAAAfAABAAAA OA1QmNYARAABAAABuQAAAEAFVEZpbGUIZGVwLnJvb3QaUk9PVCBmaWxlcyB3 aXRoIGhpc3RvZ3JhbXMAAAABAAAA8wABAAABkw1QIvQANAABAAAAxgAAAEAE VEgxUwJoMRFEaXN0cmlidXRpb24gb2YgawAAAE4AAQAAAAoNUJjWAEQAAQAA AjUAAABABVRGaWxlCGRlcC5yb290GlJPT1QgZmlsZXMgd2l0aCBoaXN0b2dy YW1zAAEAAAKDdzWUAA== --1556251094-873584403-894636441=:6542--