public static void Random_derive_uniform() { const int count = 100_000; const double μ = 100; // Mean const double σ = 10; // Sigma var normal = Uniform.FromMuSigma(μ, σ, Seed); double[] values = normal.Sample(count).ToArray(); // ~99.7% of population is within +/- 3 standard deviations const double sd = 3 * σ; int cnt = values .Where(n => n >= μ - sd && n <= μ + sd) .Count(); Assert.True(cnt >= 0.990 * count); // 99,716 double min = values.Min(); double avg = values.Average(); double max = values.Max(); Assert.True(min < avg); Assert.True(avg < max); }
public static void Random_derive_uniform_sigma_zero() { const int count = 1_000; const double μ = 100; // Mean const double σ = 0; // Sigma var normal = Uniform.FromMuSigma(μ, σ, Seed); IEnumerable <double> values = normal.Sample(count); Assert.All(values, n => Assert.True(n == μ)); }