public void bench_mkl_sfmt19937_bernoulli_i32() { using var generator = rng.sfmt19937(RngSeed.TakeSingle <uint>(0)); var sampler = generator.BernoulliSampler(BernoulliSpec.Define <int>(.35)); Benchmark(sampler); }
void Bernouli(double p, int count) { var sw = stopwatch(false); sw.Start(); var samples = BernoulliSpec <long> .Define(p).Distribution <long>(Random).Sample().Take(count); var avg = samples.Average(); sw.Stop(); }
public BernoulliDist(IPolyrand random, BernoulliSpec <T> spec) : base(random, spec) { }
public static BernoulliSpec <T> Define <T>(double p) where T : unmanaged => BernoulliSpec <T> .Define(p);
/// <summary> /// Constructs a Bernouli distribution given a specification and random source /// </summary> /// <param name="spec">A specification that characterizes the distribution</param> /// <param name="random">A (uniform) random source</param> /// <typeparam name="T">The sample element type</typeparam> public static BernoulliDist <T> Distribution <T>(this BernoulliSpec <T> spec, IPolyrand random) where T : unmanaged => new BernoulliDist <T>(random, spec);