Beispiel #1
0
        /// <summary>
        /// Generate samples by sampling a function at samples from a probability distribution, uniform between 0 and 1.
        /// Faster than other methods but with reduced guarantees on randomness.
        /// </summary>
        public static T[] UniformMap <T>(int length, Func <double, T> map)
        {
            var samples = SystemRandomSource.Doubles(length);
            var data    = new T[length];

            for (int i = 0; i < data.Length; i++)
            {
                data[i] = map(samples[i]);
            }
            return(data);
        }
Beispiel #2
0
 /// <summary>
 /// Create random samples, uniform between 0 and 1.
 /// Faster than other methods but with reduced guarantees on randomness.
 /// </summary>
 public static double[] Uniform(int length)
 {
     return(SystemRandomSource.Doubles(length));
 }
 public void StaticSamplesConsistent()
 {
     Assert.That(SystemRandomSource.Doubles(1000, 1), Is.EqualTo(new SystemRandomSource(1).NextDoubles(1000)).Within(1e-12).AsCollection);
 }