Class GammaFromShapeAndRateOpBase
Provides outgoing messages for GammaFromShapeAndRate(Double, Double), given random arguments to the function.
Inheritance
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Factors
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
public class GammaFromShapeAndRateOpBase
Methods
AverageLogFactor(Gamma, Gamma, Gamma)
Evidence message for VMP.
Declaration
[Quality(QualityBand.Experimental)]
public static double AverageLogFactor(Gamma sample, Gamma shape, Gamma rate)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Gamma | shape | Incoming message from |
Gamma | rate | 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,shape,rate) p(sample,shape,rate) log(factor(sample,shape,rate))
. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
ImproperMessageException |
|
AverageLogFactor(Gamma, Double, Double)
Evidence message for VMP.
Declaration
public static double AverageLogFactor(Gamma sample, double shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Double | shape | Constant value for |
Double | rate | 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,shape,rate))
. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
AverageLogFactor(Double, Double, Double)
Evidence message for VMP.
Declaration
public static double AverageLogFactor(double sample, double shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Double | shape | Constant value for |
Double | rate | 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,shape,rate))
. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
CalculateDerivatives(Gamma)
Calculate derivatives of \int G(x;a,b) LogGamma(x) dx wrt (a,b)
Declaration
public static Vector CalculateDerivatives(Gamma q)
Parameters
Type | Name | Description |
---|---|---|
Gamma | q | The Gamma distribution G(x;a,b). |
Returns
Type | Description |
---|---|
Vector | A 2-vector containing derivatives of \int G(x;a,b) LogGamma(x) dx wrt (a,b). |
Remarks
Calculates expectations in x=log(s) space using Gauss-Hermite quadrature. For each integral the behaviour as x->0 is subtracted from the integrand before performing quadrature to remove the singularity there.
CalculateDerivativesNaive(Gamma)
Declaration
public static Vector CalculateDerivativesNaive(Gamma q)
Parameters
Type | Name | Description |
---|---|---|
Gamma | q |
Returns
Type | Description |
---|---|
Vector |
CalculateDerivativesTrapezoid(Gamma)
Declaration
public static Vector CalculateDerivativesTrapezoid(Gamma q)
Parameters
Type | Name | Description |
---|---|---|
Gamma | q |
Returns
Type | Description |
---|---|
Vector |
ELogGamma(Gamma)
Calculates \int G(x;a,b) LogGamma(x) dx
Declaration
public static double ELogGamma(Gamma q)
Parameters
Type | Name | Description |
---|---|---|
Gamma | q | G(x;a,b) |
Returns
Type | Description |
---|---|
Double | \int G(x;a,b) LogGamma(x) dx |
LogAverageFactor(Gamma, Gamma)
Evidence message for EP.
Declaration
public static double LogAverageFactor(Gamma sample, Gamma to_sample)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Gamma | to_sample | Outgoing message to |
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_(sample) p(sample) factor(sample,shape,rate))
.
LogAverageFactor(Gamma, Gamma, Gamma)
Evidence message for EP.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static double LogAverageFactor(Gamma sample, Gamma shape, Gamma rate)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Gamma | shape | Incoming message from |
Gamma | rate | 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_(sample,shape,rate) p(sample,shape,rate) factor(sample,shape,rate))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
ImproperMessageException |
|
LogAverageFactor(Gamma, Gamma, Double)
Evidence message for EP.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static double LogAverageFactor(Gamma sample, Gamma shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Gamma | shape | Incoming message from |
Double | rate | 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(sum_(sample,shape) p(sample,shape) factor(sample,shape,rate))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
LogAverageFactor(Gamma, Double, Double)
Evidence message for EP.
Declaration
public static double LogAverageFactor(Gamma sample, double shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Double | shape | Constant value for |
Double | rate | 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(sum_(sample) p(sample) factor(sample,shape,rate))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
LogAverageFactor(Double, Gamma, Gamma)
Evidence message for EP.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static double LogAverageFactor(double sample, Gamma shape, Gamma rate)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Gamma | shape | Incoming message from |
Gamma | rate | 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_(shape,rate) p(shape,rate) factor(sample,shape,rate))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
LogAverageFactor(Double, Gamma, Double)
Evidence message for EP.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static double LogAverageFactor(double sample, Gamma shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Gamma | shape | Incoming message from |
Double | rate | 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(sum_(shape) p(shape) factor(sample,shape,rate))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
LogAverageFactor(Double, Double, Gamma)
Evidence message for EP.
Declaration
public static double LogAverageFactor(double sample, double shape, Gamma rate)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Double | shape | Constant value for |
Gamma | rate | 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_(rate) p(rate) factor(sample,shape,rate))
.
LogAverageFactor(Double, Double, Double)
Evidence message for EP.
Declaration
public static double LogAverageFactor(double sample, double shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Double | shape | Constant value for |
Double | rate | 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,shape,rate))
.
LogEvidenceRatio(Gamma, Double, Double)
Evidence message for EP.
Declaration
public static double LogEvidenceRatio(Gamma sample, double shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Double | shape | Constant value for |
Double | rate | 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(sum_(sample) p(sample) factor(sample,shape,rate) / sum_sample p(sample) messageTo(sample))
. Adding up these values across all factors and variables gives the log-evidence estimate for EP.
LogEvidenceRatio(Double, Double, Gamma)
Evidence message for EP.
Declaration
public static double LogEvidenceRatio(double sample, double shape, Gamma rate)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Double | shape | Constant value for |
Gamma | rate | 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_(rate) p(rate) factor(sample,shape,rate))
. Adding up these values across all factors and variables gives the log-evidence estimate for EP.
LogEvidenceRatio(Double, Double, Double)
Evidence message for EP.
Declaration
public static double LogEvidenceRatio(double sample, double shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Double | shape | Constant value for |
Double | rate | 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,shape,rate))
. Adding up these values across all factors and variables gives the log-evidence estimate for EP.
RateAverageConditional(Gamma, Gamma)
EP message to rate
.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static Gamma RateAverageConditional(Gamma sample, Gamma shape)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Gamma | shape | Incoming message from |
Returns
Type | Description |
---|---|
Gamma | The outgoing EP message to the |
Remarks
The outgoing message is a distribution matching the moments of rate
as the random arguments are varied. The formula is proj[p(rate) sum_(sample,shape) p(sample,shape) factor(sample,shape,rate)]/p(rate)
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
RateAverageConditional(Double, Double)
EP message to rate
.
Declaration
public static Gamma RateAverageConditional(double sample, double shape)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Double | shape | Constant value for |
Returns
Type | Description |
---|---|
Gamma | The outgoing EP message to the |
Remarks
The outgoing message is the factor viewed as a function of rate
conditioned on the given values.
RateAverageLogarithm(Gamma, Gamma)
VMP message to rate
.
Declaration
public static Gamma RateAverageLogarithm(Gamma sample, Gamma shape)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Gamma | shape | Incoming message from |
Returns
Type | Description |
---|---|
Gamma | 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 rate
. The formula is exp(sum_(sample,shape) p(sample,shape) log(factor(sample,shape,rate)))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
RateAverageLogarithm(Gamma, Double)
VMP message to rate
.
Declaration
public static Gamma RateAverageLogarithm(Gamma sample, double shape)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Double | shape | Constant value for |
Returns
Type | Description |
---|---|
Gamma | 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 rate
. The formula is exp(sum_(sample) p(sample) log(factor(sample,shape,rate)))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
RateAverageLogarithm(Double, Gamma)
VMP message to rate
.
Declaration
public static Gamma RateAverageLogarithm(double sample, Gamma shape)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Gamma | shape | Incoming message from |
Returns
Type | Description |
---|---|
Gamma | 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 rate
. The formula is exp(sum_(shape) p(shape) log(factor(sample,shape,rate)))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
RateAverageLogarithm(Double, Double)
VMP message to rate
.
Declaration
public static Gamma RateAverageLogarithm(double sample, double shape)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Double | shape | Constant value for |
Returns
Type | Description |
---|---|
Gamma | The outgoing VMP message to the |
Remarks
The outgoing message is the factor viewed as a function of rate
conditioned on the given values.
SampleAverageConditional(Gamma, Gamma)
EP message to sample
.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static Gamma SampleAverageConditional(Gamma shape, Gamma rate)
Parameters
Type | Name | Description |
---|---|---|
Gamma | shape | Incoming message from |
Gamma | rate | Incoming message from |
Returns
Type | Description |
---|---|
Gamma | 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_(shape,rate) p(shape,rate) factor(sample,shape,rate)]/p(sample)
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
SampleAverageConditional(Gamma, Double)
EP message to sample
.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static Gamma SampleAverageConditional(Gamma shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Gamma | shape | Incoming message from |
Double | rate | Constant value for |
Returns
Type | Description |
---|---|
Gamma | 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_(shape) p(shape) factor(sample,shape,rate)]/p(sample)
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
SampleAverageConditional(Double, Double)
EP message to sample
.
Declaration
public static Gamma SampleAverageConditional(double shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Double | shape | Constant value for |
Double | rate | Constant value for |
Returns
Type | Description |
---|---|
Gamma | The outgoing EP message to the |
Remarks
The outgoing message is the factor viewed as a function of sample
conditioned on the given values.
SampleAverageConditionalInit()
Declaration
public static Gamma SampleAverageConditionalInit()
Returns
Type | Description |
---|---|
Gamma |
Remarks
SampleAverageLogarithm(Gamma, Gamma)
VMP message to sample
.
Declaration
[Quality(QualityBand.Experimental)]
public static Gamma SampleAverageLogarithm(Gamma shape, Gamma rate)
Parameters
Type | Name | Description |
---|---|---|
Gamma | shape | Incoming message from |
Gamma | rate | Incoming message from |
Returns
Type | Description |
---|---|
Gamma | 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_(shape,rate) p(shape,rate) log(factor(sample,shape,rate)))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
SampleAverageLogarithm(Gamma, Double)
VMP message to sample
.
Declaration
[Quality(QualityBand.Experimental)]
public static Gamma SampleAverageLogarithm(Gamma shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Gamma | shape | Incoming message from |
Double | rate | Constant value for |
Returns
Type | Description |
---|---|
Gamma | 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_(shape) p(shape) log(factor(sample,shape,rate)))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
SampleAverageLogarithm(Double, Gamma)
VMP message to sample
.
Declaration
public static Gamma SampleAverageLogarithm(double shape, Gamma rate)
Parameters
Type | Name | Description |
---|---|---|
Double | shape | Constant value for |
Gamma | rate | Incoming message from |
Returns
Type | Description |
---|---|
Gamma | 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_(rate) p(rate) log(factor(sample,shape,rate)))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
SampleAverageLogarithm(Double, Double)
VMP message to sample
.
Declaration
public static Gamma SampleAverageLogarithm(double shape, double rate)
Parameters
Type | Name | Description |
---|---|---|
Double | shape | Constant value for |
Double | rate | Constant value for |
Returns
Type | Description |
---|---|
Gamma | The outgoing VMP message to the |
Remarks
The outgoing message is the factor viewed as a function of sample
conditioned on the given values.
ShapeAverageConditional(Gamma, Gamma, Gamma, Gamma)
EP message to shape
.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static Gamma ShapeAverageConditional(Gamma sample, Gamma shape, Gamma rate, Gamma result)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Gamma | shape | Incoming message from |
Gamma | rate | Incoming message from |
Gamma | result | Modified to contain the outgoing message. |
Returns
Type | Description |
---|---|
Gamma |
|
Remarks
The outgoing message is a distribution matching the moments of shape
as the random arguments are varied. The formula is proj[p(shape) sum_(sample,rate) p(sample,rate) factor(sample,shape,rate)]/p(shape)
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
ImproperMessageException |
|
ShapeAverageConditional(Gamma, Gamma, Double, Gamma)
EP message to shape
.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static Gamma ShapeAverageConditional(Gamma sample, Gamma shape, double rate, Gamma result)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Gamma | shape | Incoming message from |
Double | rate | Constant value for |
Gamma | result | Modified to contain the outgoing message. |
Returns
Type | Description |
---|---|
Gamma |
|
Remarks
The outgoing message is a distribution matching the moments of shape
as the random arguments are varied. The formula is proj[p(shape) sum_(sample) p(sample) factor(sample,shape,rate)]/p(shape)
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
ShapeAverageConditional(Double, Gamma, Gamma, Gamma)
EP message to shape
.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static Gamma ShapeAverageConditional(double sample, Gamma shape, Gamma rate, Gamma result)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Gamma | shape | Incoming message from |
Gamma | rate | Incoming message from |
Gamma | result | Modified to contain the outgoing message. |
Returns
Type | Description |
---|---|
Gamma |
|
Remarks
The outgoing message is a distribution matching the moments of shape
as the random arguments are varied. The formula is proj[p(shape) sum_(rate) p(rate) factor(sample,shape,rate)]/p(shape)
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
ShapeAverageConditional(Double, Gamma, Double, Gamma)
EP message to shape
.
Declaration
[NotSupported("Expectation Propagation does not support Gamma variables with stochastic shape")]
public static Gamma ShapeAverageConditional(double sample, Gamma shape, double rate, Gamma result)
Parameters
Type | Name | Description |
---|---|---|
Double | sample | Constant value for |
Gamma | shape | Incoming message from |
Double | rate | Constant value for |
Gamma | result | Modified to contain the outgoing message. |
Returns
Type | Description |
---|---|
Gamma |
|
Remarks
The outgoing message is the factor viewed as a function of shape
conditioned on the given values.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ShapeAverageLogarithm(Gamma, Gamma, Gamma, Gamma)
VMP message to shape
.
Declaration
[Quality(QualityBand.Experimental)]
public static Gamma ShapeAverageLogarithm(Gamma sample, Gamma shape, Gamma rate, Gamma to_shape)
Parameters
Type | Name | Description |
---|---|---|
Gamma | sample | Incoming message from |
Gamma | shape | Incoming message from |
Gamma | rate | Incoming message from |
Gamma | to_shape | Previous outgoing message to |
Returns
Type | Description |
---|---|
Gamma | 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 shape
. The formula is exp(sum_(sample,rate) p(sample,rate) log(factor(sample,shape,rate)))
.
Exceptions
Type | Condition |
---|---|
ImproperMessageException |
|
ImproperMessageException |
|
ImproperMessageException |
|