|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
Normal (Gaussian) random number generator. More...
#include <Normal.hpp>
Public Member Functions | |
| Normal (float mean, float std_dev) | |
| Construct a Normal generator. | |
| std::vector< float > | operator() (int count, RNG &rng) |
| Generate multiple normal variates. | |
| float | operator() (RNG &rng) |
| Generate a single normal variate via the Box-Muller transform. | |
Normal (Gaussian) random number generator.
Generates samples from N(mean, std_dev²) using the Box-Muller transform. Each call to the RNG produces a pair of independent standard normal variates; the second is cached and returned on the next invocation, so roughly half of the calls avoid the expensive trigonometric computation.
Uniform inputs are generated internally at 53-bit precision (see gen_unif01()), matching the significand width of IEEE 754 double-precision floats.
| ppforest2::stats::Normal::Normal | ( | float | mean, |
| float | std_dev ) |
Construct a Normal generator.
| mean | Distribution mean. |
| std_dev | Distribution standard deviation. |
| std::vector< float > ppforest2::stats::Normal::operator() | ( | int | count, |
| RNG & | rng ) |
Generate multiple normal variates.
| count | Number of samples to generate. |
| rng | Random number generator (pcg32). |
count samples from N(mean, std_dev²). | float ppforest2::stats::Normal::operator() | ( | RNG & | rng | ) |
Generate a single normal variate via the Box-Muller transform.
Draws two independent uniform variates U1, U2 ∈ (0, 1) and computes a pair of standard normal variates:
Z1 = √(−2 ln U1) · cos(2π U2) Z2 = √(−2 ln U1) · sin(2π U2)
Returns Z1 (after denormalization) and caches Z2 for the next call. When a cached value is available it is returned directly without generating new uniform inputs.
| rng | Random number generator (pcg32). |