/// <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) { if (length < 0) { throw new ArgumentOutOfRangeException(nameof(length)); } return(SystemRandomSource.FastDoubles(length)); }
/// <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) { if (length < 0) { throw new ArgumentOutOfRangeException(nameof(length)); } var samples = SystemRandomSource.FastDoubles(length); return(Map(samples, map)); }
/// <summary> /// Generate samples by sampling a function at sample pairs from a probability distribution, uniform between 0 and 1. /// Faster than other methods but with reduced guarantees on randomness. /// </summary> public static T[] UniformMap2 <T>(int length, Func <double, double, T> map) { if (length < 0) { throw new ArgumentOutOfRangeException("length"); } var samples1 = SystemRandomSource.FastDoubles(length); var samples2 = SystemRandomSource.FastDoubles(length); return(Map2(samples1, samples2, map)); }