export const normalRandom = (mean: number, stdDev: number, maxStdDevs = 2) => {
  const [u, v] = [0, 0].map(() => Math.random() + 1e-12);
  const normal =
    mean + stdDev * Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
  return Math.min(
    mean + maxStdDevs * stdDev,
    Math.max(mean - maxStdDevs * stdDev, normal)
  );
};
