void transformation() { double xmax = 5; TH1* h = new TH1F( "h", "Transformationsmethode", 10, 0, xmax ); h->SetMaximum( 1 ); h->SetStats( kFALSE ); h->Draw(); TH1* hdist = new TH1F( "hdist", "Histogramm fuer Zufallszahlen", 10, 0, xmax ); TF1* f = new TF1( "f", "exp(-x)", 0, xmax ); f->Draw("same"); TF1* F = new TF1( "F", "1-exp(-x)", 0, xmax ); F->SetLineColor( 4 ); F->Draw("same"); TLine* lx = 0; TLine* ly = 0; TH1* hsave = 0; for( int i = 0; i < 1000; ++ i ) { if( lx != 0 ) delete lx; if( ly != 0 ) delete ly; if( hsave != 0 ) delete hsave; double y = gRandom->Uniform(); double x = -log( y ); cout << i << "\t" << y << "\t" << x << endl; hdist->Fill( x ); TH1* hsave = hdist->DrawNormalized( "same" ); // correct by 1/(bin width) hsave->Scale( 10/xmax ); lx = new TLine( x, 0, x, 1 ); lx->Draw(); ly = new TLine( 0, y, xmax, y ); ly->Draw(); gPad->Modified(); gPad->Update(); if( i < 10 ) gPad->WaitPrimitive(); } }