Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
vavilov.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Test of the TMath::Vavilov distribution

#include "TMath.h"
#include "TCanvas.h"
#include "TRandom.h"
#include "TGraph.h"
void vavilov()
{
Int_t n = 1000;
for (Int_t i=0; i<n; i++) {
xvalues[i] = r.Uniform(-2, 10);
yvalues1[i] = TMath::Vavilov(xvalues[i], 0.3, 0.5);
yvalues2[i] = TMath::Vavilov(xvalues[i], 0.15, 0.5);
yvalues3[i] = TMath::Vavilov(xvalues[i], 0.25, 0.5);
yvalues4[i] = TMath::Vavilov(xvalues[i], 0.05, 0.5);
}
TCanvas *c1 = new TCanvas("c1", "Vavilov density");
c1->SetGrid();
c1->SetHighLightColor(19);
gr1->SetTitle("TMath::Vavilov density");
gr1->Draw("ap");
gr2->Draw("psame");
gr2->SetMarkerColor(kRed);
gr3->Draw("psame");
gr3->SetMarkerColor(kBlue);
gr4->Draw("psame");
gr4->SetMarkerColor(kGreen);
TF1 *f1 = new TF1("f1", "TMath::Vavilov(x, 0.3, 0.5)", -2, 10);
TH1F *hist = new TH1F("vavilov", "vavilov", 100, -2, 10);
for (int i=0; i<10000; i++) {
hist->Fill(f1->GetRandom());
}
hist->Scale(1/1200.);
hist->Draw("same");
}
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
The Canvas class.
Definition TCanvas.h:23
1-Dim function class
Definition TF1.h:233
virtual Double_t GetRandom(TRandom *rng=nullptr, Option_t *opt=nullptr)
Return a random number following this function shape.
Definition TF1.cxx:2192
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:622
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition TH1.cxx:3344
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3066
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
Definition TH1.cxx:6625
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
return c1
Definition legend1.C:41
const Int_t n
Definition legend1.C:16
TF1 * f1
Definition legend1.C:11
Double_t Vavilov(Double_t x, Double_t kappa, Double_t beta2)
Returns the value of the Vavilov probability density function.
Definition TMath.cxx:2778
Author
Anna Kreshuk

Definition in file vavilov.C.