public static IEnumerable <bool> SampleBernoulli(this IPolyrand random, double p) { var dist = new Dist.Bernoulli(p); while (true) { yield return(dist.Sample(random)); } }
public static IList <int> Sample(ISparseList <double> probTrue) { var result = new bool[probTrue.Count]; var list = new List <int>(); int i = 0; foreach (double d in probTrue) { if (Bernoulli.Sample(d)) { list.Add(i); } i++; } return(list); }
public bool Sample(IPolyrand random) { return(Bernoulli.Sample(GetProbTrue(), random)); }
public bool Sample() { return(Bernoulli.Sample(GetProbTrue())); }