#include <random/normal.h>

#include <math.h>

// Generate two samples in the standard normal distribution using the
// Box-Muller transform.
// https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
void normal2(double u, double v, double* z0, double* z1) {
  const double r = sqrt(-2 * log(u));
  const double x = 2 * M_PI * v;
  *z0 = r * cos(x);
  *z1 = r * sin(x);
}

double normal_transform(double z, double mu, double sigma) {
  return z*sigma + mu;
}