void chi2()
{
TF1* fG = new TF1( "Gamma", "TMath::Gamma(x)", 0, 5 );
fG->Draw();
fG->GetXaxis()->SetTitle( "x" );
fG->GetYaxis()->SetTitle( "#Gamma(x)" );
gPad->SaveAs( "Gamma.pdf" );
TF1* f[3] = { 0 };
int n[3] = { 8,9,10 };
for( int i = =; i < 3 ; ++i ) {
f[i] = new TF1( Form( "fchi2%d", i ), chisquare, 0, 20, 1 );
f[i]->SetTitle( Form( "#chi^{2}-Verteilung: n = %d", n[i] ) );
f[i]->SetMaximum( 0.5 );
f[i]->SetParameter( 0, n[i] );
f[i]->SetNpx( 1000 );
f[i]->Draw();
f[i]->GetXaxis()->SetTitle( "x" );
f[i]->GetYaxis()->SetTitle( "#chi^{2}(x;n)" );
gPad->SaveAs( Form( "chisquare%d.pdf", i ) );
}
}
double chisquare( double* x, double* par )
{
double val = x[0];
double nhalf = 0.5 * par[0];
return pow( val, nhalf - 1.0 ) * exp( -0.5*val ) / ( pow( 2, nhalf ) * TMath::Gamma( nhalf ) );
}