The OpenD Programming Language

geometricVariable

$(WIKI_D Geometric).

import mir.random.variable;
alias geometricVariable = geometricVar

Examples

import mir.random.engine;
auto rv = geometricVar(0.1);
static assert(isRandomVariable!(typeof(rv)));
size_t[ulong] hist;
foreach(_; 0..1000)
    hist[rv(rne)]++;
//import std.stdio;
//foreach(i; 0..100)
//    if(auto count = i in hist)
//        write(*count, ", ");
//    else
//        write("0, ");
//writeln();
import mir.random.engine;
Random* gen = threadLocalPtr!Random;
auto rv = GeometricVariable!double(0.1, true);
size_t[ulong] hist;
foreach(_; 0..10)
    hist[rv(gen)]++;

Meta