boxmuller C++ implementation

Viewed 51

This is my boxmuller code. I would like to know is there any way to make it faster? because I'm doing Monte Carlo Pricing need to simulate 1 million times.

using std::cout;
using std::endl;
double BoxMuller()
{
    
    double x = static_cast<double> (rand()) / RAND_MAX;
    double y = static_cast<double> (rand()) / RAND_MAX;
    double z = sqrt(-2.0 * log(x)) * cos(2 * M_PI * y);

    return z;
}

0 Answers
Related