Пример #1
0
 /// <summary>
 /// Gradient matching VMP message from factor to logOdds variable
 /// </summary>
 /// <param name="sample">Incoming message from 'sample'.</param>
 /// <param name="logOdds">Incoming message. Must be a proper distribution.  If uniform, the result will be uniform.</param>
 /// <param name="result">Previous message sent, used for damping</param>
 /// <returns>The outgoing VMP message.</returns>
 /// <remarks><para>
 /// 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.
 /// </para></remarks>
 /// <exception cref="ImproperMessageException"><paramref name="logOdds"/> is not a proper distribution</exception>
 public static Gaussian LogOddsAverageLogarithm(Bernoulli sample, [Proper, SkipIfUniform] Gaussian logOdds, Gaussian result)
 {
     if (sample.IsUniform())
     {
         return(Gaussian.Uniform());
     }
     throw new NotImplementedException("BernoulliFromLogOdds with non-observed output is not yet implemented");
 }
Пример #2
0
 public static TruncatedGaussian XAverageConditional([SkipIfUniform] Bernoulli isPositive)
 {
     if (isPositive.IsUniform())
     {
         return(TruncatedGaussian.Uniform());
     }
     if (isPositive.IsPointMass)
     {
         return(XAverageConditional(isPositive.Point));
     }
     throw new NotSupportedException("Cannot return a TruncatedGaussian when isPositive is random");
 }
Пример #3
0
        public static Gaussian XAverageLogarithm([SkipIfUniform] Bernoulli isPositive, [SkipIfUniform, Stochastic] Gaussian x, Gaussian to_X)
        {
            if (isPositive.IsPointMass)
            {
                return(XAverageLogarithm(isPositive.Point, x, to_X));
            }
            if (isPositive.IsUniform())
            {
                return(Gaussian.Uniform());
            }
            throw new NotSupportedException(NotSupportedMessage2);
            var prior = x / to_X;

            return(XAverageConditional(isPositive, prior));
        }
Пример #4
0
		/// <summary>
		/// Gradient matching VMP message from factor to logOdds variable
		/// </summary>
		/// <param name="sample">Incoming message from 'sample'.</param>
		/// <param name="logOdds">Incoming message. Must be a proper distribution.  If uniform, the result will be uniform.</param>
		/// <param name="result">Previous message sent, used for damping</param>
		/// <returns>The outgoing VMP message.</returns>
		/// <remarks><para>
		/// 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.
		/// </para></remarks>
		/// <exception cref="ImproperMessageException"><paramref name="logOdds"/> is not a proper distribution</exception>
		public static Gaussian LogOddsAverageLogarithm(Bernoulli sample, [Proper, SkipIfUniform] Gaussian logOdds, Gaussian result)
		{
			if (sample.IsUniform()) return Gaussian.Uniform();
			throw new NotImplementedException("BernoulliFromLogOdds with non-observed output is not yet implemented");
		}