Esempio n. 1
0
 /// <summary>
 /// Gets the log-integral of the product of this Wishart with another Wishart
 /// </summary>
 /// <param name="that">The other Wishart</param>
 /// <returns>The log inner product</returns>
 public double GetLogAverageOf(Wishart that)
 {
     if (IsPointMass)
     {
         return(that.GetLogProb(Point));
     }
     else if (that.IsPointMass)
     {
         return(GetLogProb(that.Point));
     }
     else
     {
         Wishart product = this * that;
         //if (!product.IsProper()) throw new ArgumentException("The product is improper.");
         return(product.GetLogNormalizer() - this.GetLogNormalizer() - that.GetLogNormalizer());
     }
 }
Esempio n. 2
0
 /// <summary>
 /// The expected logarithm of that distribution under this distribution.
 /// </summary>
 /// <param name="that">The distribution to take the logarithm of.</param>
 /// <returns><c>sum_x this.Evaluate(x)*Math.Log(that.Evaluate(x))</c></returns>
 /// <remarks>This is also known as the cross entropy.</remarks>
 public double GetAverageLog(Wishart that)
 {
     if (that.IsPointMass)
     {
         if (this.IsPointMass && (this.Point == that.Point))
         {
             return(0.0);
         }
         else
         {
             return(Double.NegativeInfinity);
         }
     }
     else
     {
         // that is not a point mass.
         double result = (that.Shape - 0.5 * (that.Dimension + 1)) * this.GetMeanLogDeterminant();
         result -= Matrix.TraceOfProduct(this.GetMean(), that.Rate);
         result -= that.GetLogNormalizer();
         return(result);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Get the integral of this distribution times another distribution raised to a power.
 /// </summary>
 /// <param name="that"></param>
 /// <param name="power"></param>
 /// <returns></returns>
 public double GetLogAverageOfPower(Wishart that, double power)
 {
     if (IsPointMass)
     {
         return(power * that.GetLogProb(Point));
     }
     else if (that.IsPointMass)
     {
         if (power < 0)
         {
             throw new DivideByZeroException("The exponent is negative and the distribution is a point mass");
         }
         return(this.GetLogProb(that.Point));
     }
     else
     {
         var product = this * (that ^ power);
         return(product.GetLogNormalizer() - this.GetLogNormalizer() - power * that.GetLogNormalizer());
     }
 }