Select a mean for each gaussian, and a common variance. For multi-dimensional gaussians, the mean will be a vector. To generate a point, pick one of these gaussians at random, and then generate each dimension of the point by calling a function like the one above (with the mean value for that dimension). Make sure you plot your data to make sure it looks right before you use it with your learning algorithm.double generate_normal_rv(const double mean, const double std_dev) {
const double theta = generate_uniform_rv(0.0, 2.0 * M_PI);
const double r = sqrt(-2.0 * log(generate_uniform_rv(0.0, 1.0)));
return (std_dev * r * cos(theta)) + mean;
}
| Page written by Bill Smart. |