Esempio n. 1
0
        public static IEnumerable <bool> SampleBernoulli(this IPolyrand random, double p)
        {
            var dist = new Dist.Bernoulli(p);

            while (true)
            {
                yield return(dist.Sample(random));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Sets this instance to have the parameters of another instance
 /// </summary>
 /// <param name="that">The source Bernoulli distribution</param>
 public void SetTo(Bernoulli that)
 {
     LogOdds = that.LogOdds;
 }
Esempio n. 3
0
 /// <summary>
 /// Creates the complementary distribution
 /// </summary>
 /// <param name="dist">The original distribution</param>
 /// <returns>The complementary distribution</returns>
 public static Bernoulli operator !(Bernoulli dist)
 {
     return(Bernoulli.FromLogOdds(-dist.LogOdds));
 }
Esempio n. 4
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="that"></param>
 public Bernoulli(Bernoulli that)
 {
     LogOdds = that.LogOdds;
 }
Esempio n. 5
0
 public bool Sample(IPolyrand random)
 {
     return(Bernoulli.Sample(GetProbTrue(), random));
 }
Esempio n. 6
0
 public bool Sample()
 {
     return(Bernoulli.Sample(GetProbTrue()));
 }