import mir.random; auto rv = binomialVar(20, 0.5); static assert(isRandomVariable!(typeof(rv))); int[] hist = new int[rv.max + 1]; auto cnt = 1000; foreach(_; 0..cnt) hist[rv(rne)]++; //import std.stdio; //foreach(n, e; hist) // writefln("p(x = %s) = %s", n, double(e) / cnt);
import mir.random.engine; Random* gen = threadLocalPtr!Random; auto rv = BinomialVariable!double(20, 0.5); int[] hist = new int[rv.max + 1]; auto cnt = 10; foreach(_; 0..cnt) hist[rv(gen)]++;
$(WIKI_D Binomial).