﻿Bernoulli Structure
 Bernoulli Structure
Microsoft Research
Represents a distribution on a binary variable.

Namespace: MicrosoftResearch.Infer.Distributions
Assembly: Infer.Runtime (in Infer.Runtime.dll) Version: 2.6.41128.1 (2.6.41128.1)
Syntax
```[SerializableAttribute]
[Quality(QualityBand.Mature)]
public struct Bernoulli : IDistribution<bool>,
ICloneable, HasPoint<bool>, Diffable, CanGetLogProb<bool>,
SettableTo<Bernoulli>, SettableToProduct<Bernoulli>, SettableToProduct<Bernoulli, Bernoulli>,
SettableToUniform, SettableToRatio<Bernoulli>, SettableToRatio<Bernoulli, Bernoulli>,
SettableToPower<Bernoulli>, SettableToWeightedSumExact<Bernoulli>, SettableToWeightedSum<Bernoulli>,
Sampleable<bool>, CanGetMean<double>, CanSetMean<double>,
CanGetVariance<double>, CanGetLogAverageOf<Bernoulli>, CanGetLogAverageOfPower<Bernoulli>,
CanGetAverageLog<Bernoulli>, CanGetLogNormalizer, CanGetMode<bool>```

The Bernoulli type exposes the following members.

Constructors
NameDescription
Bernoulli(Double)
Creates a Bernoulli distribution with given probability of being true.
Bernoulli(Bernoulli)
Copy constructor.
Top
Methods
NameDescription
Clone
Clones this Bernoulli.
FromLogOdds
Instantiates a Bernoulli distribution from a log-odds value
Gate
Computes the Bernoulli gating function in the log-odds domain.
GetAverageLog
The expected logarithm of that distribution under this distribution.
GetLogAverageOf
Log of the probability that a draw from this distribution is equal to a draw from that distribution.
GetLogAverageOfPower
Get the integral of this distribution times another distribution raised to a power.
GetLogNormalizer
Gets the log normalizer of the distribution
GetLogProb
Evaluates the logarithm of the density function
GetLogProbFalse
Gets the log probability of the binary variable being false
GetLogProbTrue
Gets the log probability of the binary variable being true
GetMean
Gets the mean of this Bernoulli distribution
GetMode
The most probable value.
GetProbFalse
Gets the probability of the binary variable being false
GetProbTrue
Gets the probability of the binary variable being true
GetVariance
Gets the variance of this Bernoulli distribution
IsUniform
Whether the distribution is uniform
LogitProbEqual
Computes the logical AreEqual function in the log-odds domain.
LogProbEqual
Computes the log-probability that A==B where p(A)=Logistic(x), p(B)=Logistic(y).
MaxDiff
The maximum 'difference' between this instance and that instance. This returns the absolute difference between the Log-odds
Or
Computes the logical OR function in the log-odds domain.
PointMass
Instantiates a point-mass Bernoulli distribution
Sample
Samples from a Bernoulli distribution
Sample(Boolean)
Sample(Double)
Samples from a Bernoulli distribution with a specified p(true)
SetLogProbFalse
Sets the log probability of the binary variable being false
SetLogProbTrue
Sets the log probability of the binary variable being true
SetMean
Sets the mean of this Bernoulli distribution
SetProbFalse
Sets the probability of the binary variable being false
SetProbTrue
Sets the probability of the binary variable being true
SetTo
Sets this instance to have the parameters of another instance
SetToPower
Sets this instance to the power of a Bernoulli distributions
SetToProduct
Sets this instance to a product of two Bernoulli distributions
SetToRatio
Sets this instance to a ratio of two Bernoulli distributions
SetToSum
Creates a Bernoulli distribution which is a weighted sum of two Bernoulli distribution
SetToUniform
Sets the distribution to uniform
Uniform
Instantiates a uniform Bernoulli distribution
Top
Operators
NameDescription
Division
Creates a Bernoulli distribution which is the ratio of two Bernoulli distribution
Equality
Equals operator
ExclusiveOr
Raises this distribution to a power.
Inequality
Not equals operator
LogicalNot
Creates the complementary distribution
Multiply
Creates a Bernoulli distribution which is the product of two Bernoulli distribution
Top
Fields
NameDescription
LogOdds
Log odds parameter
Top
Properties
NameDescription
IsPointMass
Whether the distribution is a point mass (true with probability 1 or false with probability 1)
Point
Gets/sets the distribution as a point
Top
Remarks
The most common way to use the distribution is to get and set its ProbTrue property. The distribution is represented by a single number, the log odds: log p(x=true)/p(x=false). If this is 0, then the distribution is uniform. If this is infinity, then the distribution is a point mass on x=true. If this is -infinity, then the distribution is a point mass on x=false. In terms of the log odds, p(x=true) = 1/(1+exp(-logOdds)).