/// <summary> /// Defines a sample stream for a poisson distribution which represents the probability of /// a given number of independent events occurring over a period of time at a constant rate /// </summary> /// <param name="random">The random source</param> /// <param name="lambda">The constant rate of occurrence</param> public static IEnumerable <int> SamplePoisson(this IPolyrand random, double lambda) { var sysrand = SysRand.Derive(random); while (true) { yield return(MlStats.SampleFromPoisson(sysrand, lambda)); } }
/// <summary> /// Defines a sample stream for a poisson distribution which represents the probability of /// a given number of independent events occurring over a period of time at a constant rate /// </summary> /// <param name="random">The random source</param> /// <param name="lambda">The constant rate of occurrence</param> public static IEnumerable <T> SamplePoisson <T>(this IPolyrand random, T lambda) where T : struct { var sysrand = SysRand.Derive(random); var l = convert <T, double>(lambda); while (true) { yield return(convert <T>(MlStats.SampleFromPoisson(sysrand, l))); } }