// 4. Exponential public static double Exponential(double stream, double locate, double scale) { int istream = (int)stream; double randValue = RandomGenerators.GetRandom(istream).NextDouble(); return(locate + (-scale * System.Math.Log(1 - randValue))); }
// 23. Uniform public static double Uniform(double stream, double min, double max) { int istream = (int)stream; double randValue = RandomGenerators.GetRandom(istream).NextDouble(); return(randValue * (max - min) + min); }
// 17. Normal public static double Normal(double stream, double mean, double stdDev) { int istream = (int)stream; Random rand = RandomGenerators.GetRandom(istream); const int n = 1000; double result = 0; for (int i = 0; i < n; i++) { result += rand.NextDouble(); } result = (result - (n / 2)) / System.Math.Sqrt(n / 12d); result = result * stdDev + mean; return(result); }