C++11 fisher_f distribution random number generator

The C++11 random fisher_f distribution( or fisher_f_distribution) produces random numbers x≥0 using the respective discrete probability function of the distribution-the function is shown at the end of the post.

Link :C++11 random number generator
C++11 random fisher_f distribution

The distribution class declaration is shown below.

template<class RealType = double&>
class fisher_f_distribution;

The class default type is double type and note this distribution can generate only floating point type values or real numbers.

The distribution is based on the the fisher_f_distribution of the probability distribution.

The types and member functions of the class is shown below.


typedef RealType result_type;

typedef unspecified param_type;

The RealType is a type definition of the template type and the param_type is a structure but note the definition of the param_type will alter from compiler to compiler.

Constructors and reset function

explicit fisher_f_distribution(RealType m = 1 , RealType n = 1);

explicit fisher_f_distribution(const param_type& parm); 

void reset( );

The first constructor accepts two parameters ‘m’ and ‘n’ whose default values are 1 and 1.These default values will be same in all compiler.And the uses of these two parameters is to evaluate the probability of the random values in the distribution.The relation 0<m and 0 <n should hold.

The second constructor accept param_type object and in this case the values of ‘m’ and ‘n’ is deduced from the ‘m’ and ‘n’ values of the param_type object.

fisher_f_distribution< >fd ;

fisher_f_distribution<float > fd1;

fisher_f_distribution< float >::param_type pt( 5.1 , 6 ) ;

fisher_f_distribution< long double >: fd2(pt) ; //error! , type of pt is float but type of fd2 is double type


The reset( ) function reset the distribution state.

Generating functions

template<class URNG>
result_type operator( )(URNG& g); 

template<class URNG>

result_type operator( )(URNG& g, const param_type& parm);
the first operator() function

The generated random sequence is obtained using the operator() function.The first overloaded operator() accept URNG(Uniform Random Number Generator) or engine.

fisher_f_distribution< >fd ;

default_random_engine dre ;

cout<< fd(dre) << ” ” << fd(dre) << endl ;

Output in Code::blocks,

0.000814409   1.41975

the second operator( ) function

The second overloaded operator( ) function accept URNG and param_type object.

fisher_f_distribution<float >fd ;

fisher_f_distribution< float >::param_type pt(5.1 , 6 ) ;

linear_congruential_engine<unsigned int , 193703 , 0 , 83474882 > lce ; //an engine

cout<< fd(lce , pt) << ” ” << fd(lce , pt) << endl ;

Output in Code::blocks,

0.449851   0.325739

Property functions

result_type m( ) const ;

result_type n() const; 

param_type param() const; 

void param(const param_type& parm); 

result_type min() const;

result_type max() const;
m() function

This function returns the ‘m’ value of the distribution.

fisher_f_distribution< >fd ,

fd1( 900 , 10);

cout<< fd.m() << endl
<< fd1.m() ;



n() function

This function returns the ‘n’ value of the distribution.

fisher_f_distribution< >fd ,

fd1( 900 , 10);

cout<< fd.n() << endl
<< fd1.n() ;




This function returns the param_type object.

fisher_f_distribution< >fd( 123 , 893);

cout<< fd.param().m() << endl
<< fd.param().n() ;




Using this function we can change the ‘m’ and ‘n’ value of the distribution to the ‘m’ and ‘n’ value of the param_type object by passing the param_type object.

fisher_f_distribution<float > fd(5000 , 100);

cout<< fd.m() << endl ;

fisher_f_distribution< float >::param_type pt( 56.01 , 6.7 ) ;

fd.param( pt );

cout<< fd.n() ;



min() function

The min() returns the smallest value the distribution can generate,which is the value 0.

fisher_f_distribution<float > fd(5000 , 100);

cout<< fd.min( );



max() function

The max() returns the largest value the distribution can generate.It returns the value of numeric_limits<result_type>::max().

fisher_f_distribution<float > fd(5000 , 100);

cout<< fd.max( );



Side note

fisher_f_distribution produces random numbers x distributed according to the probability density function,

C++11 fisher_f distribution random number generator