Class MultinomialOp
Provides outgoing messages for the following factors:
, given random arguments to the function.Inherited Members
Namespace: Microsoft.ML.Probabilistic.Factors
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
[FactorMethod(new string[]{"sample", "trialCount", "p"}, typeof(Rand), "Multinomial", new Type[]{typeof(int), typeof(Vector)})]
[FactorMethod(typeof(Factor), "MultinomialList", new Type[]{typeof(int), typeof(Vector)})]
[Buffers(new string[]{"MeanLog"})]
[Quality(QualityBand.Preview)]
public static class MultinomialOp
Remarks
The factor is f(sample,p,n) = n!/prod_k sample[k]! prod_k p[k]^sample[k]
Methods
AverageLogFactor(IList<Int32>, Int32, Dirichlet, Vector)
Evidence message for VMP.
Declaration
public static double AverageLogFactor(IList<int> sample, int trialCount, Dirichlet p, Vector MeanLog)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | sample | Incoming message from |
Int32 | trialCount | Constant value for |
Dirichlet | p | Incoming message from |
Vector | MeanLog | Buffer |
Returns
Type | Description |
---|---|
Double | Average of the factor's log-value across the given argument distributions. |
Remarks
The formula for the result is sum_(multinomial,probs) p(multinomial,probs) log(factor(multinomial,trialCount,probs))
. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
AverageLogFactor(IList<Int32>, Int32, IList<Double>)
Evidence message for VMP.
Declaration
public static double AverageLogFactor(IList<int> sample, int trialCount, IList<double> p)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | sample | Incoming message from |
Int32 | trialCount | Constant value for |
IList<Double> | p | 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_(multinomial,probs) p(multinomial,probs) log(factor(multinomial,trialCount,probs))
. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
LogAverageFactor(IList<Int32>, Int32, Dirichlet)
Evidence message for EP.
Declaration
public static double LogAverageFactor(IList<int> sample, int trialCount, Dirichlet p)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | sample | Incoming message from |
Int32 | trialCount | Constant value for |
Dirichlet | p | 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_(multinomial,probs) p(multinomial,probs) factor(multinomial,trialCount,probs))
.
LogAverageFactor(IList<Int32>, Int32, IList<Double>)
Evidence message for EP.
Declaration
public static double LogAverageFactor(IList<int> sample, int trialCount, IList<double> p)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | sample | Incoming message from |
Int32 | trialCount | Constant value for |
IList<Double> | p | 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_(multinomial,probs) p(multinomial,probs) factor(multinomial,trialCount,probs))
.
LogEvidenceRatio(IList<Discrete>)
Evidence message for EP.
Declaration
public static double LogEvidenceRatio(IList<Discrete> sample)
Parameters
Type | Name | Description |
---|---|---|
IList<Discrete> | 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_(multinomial) p(multinomial) factor(multinomial,trialCount,probs) / sum_multinomial p(multinomial) messageTo(multinomial))
. Adding up these values across all factors and variables gives the log-evidence estimate for EP.
LogEvidenceRatio(IList<Int32>, Int32, Dirichlet)
Evidence message for EP.
Declaration
public static double LogEvidenceRatio(IList<int> sample, int trialCount, Dirichlet p)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | sample | Incoming message from |
Int32 | trialCount | Constant value for |
Dirichlet | p | 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_(multinomial,probs) p(multinomial,probs) factor(multinomial,trialCount,probs) / sum_multinomial p(multinomial) messageTo(multinomial))
. Adding up these values across all factors and variables gives the log-evidence estimate for EP.
LogEvidenceRatio(IList<Int32>, Int32, IList<Double>)
Evidence message for EP.
Declaration
public static double LogEvidenceRatio(IList<int> sample, int trialCount, IList<double> p)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | sample | Incoming message from |
Int32 | trialCount | Constant value for |
IList<Double> | p | 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_(multinomial,probs) p(multinomial,probs) factor(multinomial,trialCount,probs) / sum_multinomial p(multinomial) messageTo(multinomial))
. Adding up these values across all factors and variables gives the log-evidence estimate for EP.
MeanLog(Dirichlet)
Update the buffer MeanLog
.
Declaration
public static Vector MeanLog(Dirichlet p)
Parameters
Type | Name | Description |
---|---|---|
Dirichlet | p | Incoming message from |
Returns
Type | Description |
---|---|
Vector | New value of buffer |
Remarks
PAverageConditional(IList<Int32>, Int32)
EP message to probs
.
Declaration
public static Dirichlet PAverageConditional(IList<int> sample, int trialCount)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | sample | Incoming message from |
Int32 | trialCount | Constant value for |
Returns
Type | Description |
---|---|
Dirichlet | The outgoing EP message to the |
Remarks
The outgoing message is a distribution matching the moments of probs
as the random arguments are varied. The formula is proj[p(probs) sum_(multinomial) p(multinomial) factor(multinomial,trialCount,probs)]/p(probs)
.
PAverageLogarithm(IList<Int32>, Int32)
VMP message to probs
.
Declaration
public static Dirichlet PAverageLogarithm(IList<int> sample, int trialCount)
Parameters
Type | Name | Description |
---|---|---|
IList<Int32> | sample | Incoming message from |
Int32 | trialCount | Constant value for |
Returns
Type | Description |
---|---|
Dirichlet | 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 probs
. The formula is exp(sum_(multinomial) p(multinomial) log(factor(multinomial,trialCount,probs)))
.