dimanche 26 février 2017

C++ Random Number Generation: Generate cos squared function

The probability distribution of interest is

double x; // range: -pi/2.0 to +pi/2.0
double y = std::pow(std::cos(x), 2.0);

This function can be integrated analytically, however it cannot be inverted. Therefore the usual trick of mapping a uniform distribution to the required probability distribution cannot be performed.

Is there another method which can be used to generate a random variable cos^2(theta) distribution?

It may be possible to find the inverse function numerically, however I do not know of an efficient (memory and computationally) method of doing this.




Aucun commentaire:

Enregistrer un commentaire