/// <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)); }
/// <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; }
/// <summary> /// Copy constructor. /// </summary> /// <param name="that"></param> public Bernoulli(Bernoulli that) { LogOdds = that.LogOdds; }
public bool Sample() { return(Bernoulli.Sample(GetProbTrue())); }
/// <summary> /// Initializes a new instance of the <see cref="BernoulliIntegerSubset"/> class /// of a given length and assigns all elements the given value, /// except for the specified list of sparse values. This list is stored internally as is, /// so MUST be sorted by index and must not be modified externally after being passed in. /// </summary> /// <param name="size">The size of the list.</param> /// <param name="commonValue">The common value.</param> /// <param name="sortedSparseValues">The sorted list of non-common values.</param> protected BernoulliIntegerSubset(int size, Bernoulli commonValue, List <ValueAtIndex <Bernoulli> > sortedSparseValues) { SparseBernoulliList = SparseBernoulliList.FromSparseValues(size, commonValue, sortedSparseValues); }
/// <summary> /// Initializes a new instance of the <see cref="BernoulliIntegerSubset"/> class /// of the given size, and assigns all elements to the specified common value. /// </summary> /// <param name="size">The size of the list.</param> /// <param name="commonValue">The common value.</param> protected BernoulliIntegerSubset(int size, Bernoulli commonValue) { SparseBernoulliList = SparseBernoulliList.Constant(size, commonValue); }
/// <summary> /// Returns a new instance of the <see cref="BernoulliIntegerSubset"/> class with the specified number of elements /// all of which are set to the specified <see cref="Bernoulli"/> instance. /// </summary> /// <param name="size">The size of the list.</param> /// <param name="commonValue">The common value.</param> /// <returns>The new <see cref="BernoulliIntegerSubset"/> instance.</returns> public static BernoulliIntegerSubset FromBernoulli(int size, Bernoulli commonValue) { return(BernoulliIntegerSubset.FromBernoulli(size, commonValue, SparseBernoulliList.DefaultTolerance)); }