Class BernoulliFromLogOddsOp
Provides outgoing messages for BernoulliFromLogOdds(Double), given random arguments to the function.
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Factors
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
[FactorMethod(typeof(Factor), "BernoulliFromLogOdds", new Type[]{})]
[Quality(QualityBand.Experimental)]
public static class BernoulliFromLogOddsOp
Remarks
Performs KL minimization using gradient matching, a distributed gradient descent algorithm.
Fields
ForceProper
Declaration
public static bool ForceProper
Field Value
Type | Description |
---|---|
Boolean |
Methods
AverageLogFactor(Bernoulli, Gaussian)
Evidence message for VMP.
Declaration
public static double AverageLogFactor(Bernoulli sample, Gaussian logOdds)
Parameters
Type | Name | Description |
---|---|---|
Bernoulli | sample | Incoming message from |
Gaussian | logOdds | Incoming message from |
Returns
Type | Description |
---|---|
Double | Average of the factor's log-value across the given argument distributions. |
Remarks
The formula for the result is sum_(sample,logOdds) p(sample,logOdds) log(factor(sample,logOdds))
. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
AverageLogFactor(Bernoulli, Double)
Evidence message for VMP.
Declaration
public static double AverageLogFactor(Bernoulli sample, double logOdds)
Parameters
Type | Name | Description |
---|---|---|
Bernoulli | sample | Incoming message from |
Double | logOdds | Constant value for |
Returns
Type | Description |
---|---|
Double | Average of the factor's log-value across the given argument distributions. |
Remarks
The formula for the result is sum_(sample) p(sample) log(factor(sample,logOdds))
. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
AverageLogFactor(Boolean, Gaussian)
Evidence message for VMP.
Declaration
public static double AverageLogFactor(bool sample, Gaussian logOdds)
Parameters
Type | Name | Description |
---|---|---|
Boolean | sample | Constant value for |
Gaussian | logOdds | Incoming message from |
Returns
Type | Description |
---|---|
Double | Average of the factor's log-value across the given argument distributions. |
Remarks
The formula for the result is sum_(logOdds) p(logOdds) log(factor(sample,logOdds))
. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
AverageLogFactor(Boolean, Double)
Evidence message for VMP.
Declaration
public static double AverageLogFactor(bool sample, double logOdds)
Parameters
Type | Name | Description |
---|---|---|
Boolean | sample | Constant value for |
Double | logOdds | Constant value for |
Returns
Type | Description |
---|---|
Double | Average of the factor's log-value across the given argument distributions. |
Remarks
The formula for the result is log(factor(sample,logOdds))
. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
LogAverageFactor(Boolean, Gaussian)
Evidence message for EP.
Declaration
public static double LogAverageFactor(bool sample, Gaussian logOdds)
Parameters
Type | Name | Description |
---|---|---|
Boolean | sample | Constant value for |
Gaussian | logOdds | Incoming message from |
Returns
Type | Description |
---|---|
Double | Logarithm of the factor's average value across the given argument distributions. |
Remarks
The formula for the result is log(sum_(logOdds) p(logOdds) factor(sample,logOdds))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
LogAverageFactor(Boolean, Double)
Evidence message for EP.
Declaration
public static double LogAverageFactor(bool sample, double logOdds)
Parameters
Type | Name | Description |
---|---|---|
Boolean | sample | Constant value for |
Double | logOdds | Constant value for |
Returns
Type | Description |
---|---|
Double | Logarithm of the factor's average value across the given argument distributions. |
Remarks
The formula for the result is log(factor(sample,logOdds))
.
LogEvidenceRatio(Bernoulli)
Evidence message for EP.
Declaration
public static double LogEvidenceRatio(Bernoulli sample)
Parameters
Type | Name | Description |
---|---|---|
Bernoulli | sample | Incoming message from |
Returns
Type | Description |
---|---|
Double | Logarithm of the factor's contribution the EP model evidence. |
Remarks
The formula for the result is log(sum_(sample) p(sample) factor(sample,logOdds) / sum_sample p(sample) messageTo(sample))
. Adding up these values across all factors and variables gives the log-evidence estimate for EP.
LogEvidenceRatio(Boolean, Gaussian)
Evidence message for EP.
Declaration
public static double LogEvidenceRatio(bool sample, Gaussian logOdds)
Parameters
Type | Name | Description |
---|---|---|
Boolean | sample | Constant value for |
Gaussian | logOdds | Incoming message from |
Returns
Type | Description |
---|---|
Double | Logarithm of the factor's contribution the EP model evidence. |
Remarks
The formula for the result is log(sum_(logOdds) p(logOdds) factor(sample,logOdds))
. Adding up these values across all factors and variables gives the log-evidence estimate for EP.
LogEvidenceRatio(Boolean, Double)
Evidence message for EP.
Declaration
public static double LogEvidenceRatio(bool sample, double logOdds)
Parameters
Type | Name | Description |
---|---|---|
Boolean | sample | Constant value for |
Double | logOdds | Constant value for |
Returns
Type | Description |
---|---|
Double | Logarithm of the factor's contribution the EP model evidence. |
Remarks
The formula for the result is log(factor(sample,logOdds))
. Adding up these values across all factors and variables gives the log-evidence estimate for EP.
LogOddsAverageConditional(Bernoulli, Gaussian)
EP message to logOdds
.
Declaration
public static Gaussian LogOddsAverageConditional(Bernoulli sample, Gaussian logOdds)
Parameters
Type | Name | Description |
---|---|---|
Bernoulli | sample | Incoming message from |
Gaussian | logOdds | Incoming message from |
Returns
Type | Description |
---|---|
Gaussian | The outgoing EP message to the |
Remarks
The outgoing message is a distribution matching the moments of logOdds
as the random arguments are varied. The formula is proj[p(logOdds) sum_(sample) p(sample) factor(sample,logOdds)]/p(logOdds)
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
LogOddsAverageConditional(Boolean, Gaussian)
EP message to logOdds
.
Declaration
public static Gaussian LogOddsAverageConditional(bool sample, Gaussian logOdds)
Parameters
Type | Name | Description |
---|---|---|
Boolean | sample | Constant value for |
Gaussian | logOdds | Incoming message from |
Returns
Type | Description |
---|---|
Gaussian | The outgoing EP message to the |
Remarks
The outgoing message is the factor viewed as a function of logOdds
conditioned on the given values.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
LogOddsAverageLogarithm(Bernoulli, Gaussian, Gaussian)
Gradient matching VMP message from factor to logOdds variable
Declaration
public static Gaussian LogOddsAverageLogarithm(Bernoulli sample, Gaussian logOdds, Gaussian result)
Parameters
Type | Name | Description |
---|---|---|
Bernoulli | sample | Incoming message from 'sample'. |
Gaussian | logOdds | Incoming message. Must be a proper distribution. If uniform, the result will be uniform. |
Gaussian | result | Previous message sent, used for damping |
Returns
Type | Description |
---|---|
Gaussian | The outgoing VMP message. |
Remarks
The outgoing message is the Gaussian approximation to the factor which results in the same derivatives of the KL(q||p) divergence with respect to the parameters of the posterior as if the true factor had been used.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
LogOddsAverageLogarithm(Boolean, Gaussian, Gaussian)
Gradient matching VMP message from factor to logOdds variable
Declaration
public static Gaussian LogOddsAverageLogarithm(bool sample, Gaussian logOdds, Gaussian to_LogOdds)
Parameters
Type | Name | Description |
---|---|---|
Boolean | sample | Constant value for 'sample'. |
Gaussian | logOdds | Incoming message. Must be a proper distribution. If uniform, the result will be uniform. |
Gaussian | to_LogOdds | Previous message sent, used for damping |
Returns
Type | Description |
---|---|
Gaussian | The outgoing VMP message. |
Remarks
The outgoing message is the Gaussian approximation to the factor which results in the same derivatives of the KL(q||p) divergence with respect to the parameters of the posterior as if the true factor had been used.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
SampleAverageConditional(Gaussian)
EP message to sample
.
Declaration
public static Bernoulli SampleAverageConditional(Gaussian logOdds)
Parameters
Type | Name | Description |
---|---|---|
Gaussian | logOdds | Incoming message from |
Returns
Type | Description |
---|---|
Bernoulli | The outgoing EP message to the |
Remarks
The outgoing message is a distribution matching the moments of sample
as the random arguments are varied. The formula is proj[p(sample) sum_(logOdds) p(logOdds) factor(sample,logOdds)]/p(sample)
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
SampleAverageLogarithm(Gaussian)
VMP message to sample
.
Declaration
public static Bernoulli SampleAverageLogarithm(Gaussian logOdds)
Parameters
Type | Name | Description |
---|---|---|
Gaussian | logOdds | Incoming message from |
Returns
Type | Description |
---|---|
Bernoulli | The outgoing VMP message to the |
Remarks
The outgoing message is the exponential of the average log-factor value, where the average is over all arguments except sample
. The formula is exp(sum_(logOdds) p(logOdds) log(factor(sample,logOdds)))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
SampleAverageLogarithm(Double)
VMP message to sample
.
Declaration
public static Bernoulli SampleAverageLogarithm(double logOdds)
Parameters
Type | Name | Description |
---|---|---|
Double | logOdds | Constant value for |
Returns
Type | Description |
---|---|
Bernoulli | The outgoing VMP message to the |
Remarks
The outgoing message is the factor viewed as a function of sample
conditioned on the given values.