List of valid random generators

Is there a list of valid generators that can be called for a TH1? in all the examples I can find only “gaus” is used

TH1F* h1 =new TH1F();
h1->FillRandom("gaus",1000);

The TRandom class reference suggests there’s others that can be called but doesn’t seem to list the names that FillRandom will accept

update:
I dug into the source code and tracked the predefined functions back to line 2488 of TF1.cxx. But the question of are these functions listed anywhere in the documentation still remains

TH1::FillRandom can be used to randomly fill an histogram using the contents of an existing TF1 function or another TH1 histogram (for all dimensions).

I never defined the “gaus” function above, so it’s predefined somewhere. But I can’t find a list of the predefined function names, except in the source code

((TF1*)gROOT->GetFunction("gaus"))->Print();
gROOT->GetListOfFunctions()->ls();

Thanks, That worked. Are the functions listed in the documentation anywhere? Or is this the only way to find them?

You can define your own TF1 functions.

yes i could. but if i want to quickly test something it’s easier to just use the predefined functions and in for the case i’m testing now I needed 2. I was just trying to find a list of the predefined functions in the documentation. Does it exist?

TF1::InitStandardFunctions();
gROOT->GetListOfFunctions()->ls();

@couet I mean in the documentation. Like in the tf1 or th1 class reference. Somewhere that doesn’t require a user to know a specific command

@moneta will know better which part of the documentation should be updated.

Hi,
We should probably update the TF1 reference documentation with the list of predefined functions which are created calling TF1::InitStandardFunctions() and then available globally in the functionalist of TROOT ( `gROOT->getListOfFunctions() ).
We should add a link to the documentation of the predefined functions also in the reference doc of TROOT.

In addition, I see that TF1::InitStandardFunctions() is called automatically when calling TROOT::GetFunction(name). We should probably called it also when the users just asks for TROOT::GetListOfFunctions()

Lorenzo

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.