Exemple #1
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(Discrete 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
     {
         return(Math.Log(prob.Reduce(0.0, that.prob, (partial, thisp, thatp) => (partial + thisp * Math.Pow(thatp, power)))));
     }
 }
 /// <summary>
 /// Evaluates the log density at the specified domain value
 /// </summary>
 /// <param name="value">The point at which to evaluate</param>
 /// <returns>The log density</returns>
 public double GetLogProb(T value)
 {
     return(disc.GetLogProb(ConvertToInt(value)));
 }