/// <summary>
 /// Convert to the optimal Gaussian
 /// </summary>
 /// <returns></returns>
 public Gaussian GetGaussian()
 {
     if (Precision == 0.0 || Rate == 0.0)
     {
         return(Gaussian.Uniform());
     }
     return(Gaussian.FromMeanAndVariance(MeanTimesPrecision / Precision, (Shape - 1) / Rate));
 }
 /// <summary>
 /// Convert to the optimal Gaussian
 /// </summary>
 /// <param name="addEntropy">Whether to include an entropy term</param>
 /// <returns></returns>
 public Gaussian GetGaussian(bool addEntropy)
 {
     if (Precision == 0.0 || Rate == 0.0)
     {
         return(Gaussian.Uniform());
     }
     return(Gaussian.FromMeanAndVariance(MeanTimesPrecision / Precision, (Shape - 1 + (addEntropy ? .5 : 0)) / Rate));
 }
Exemple #3
0
 /// <summary>
 /// Create a truncated Gaussian from untruncated (mean, variance) and bounds
 /// </summary>
 /// <param name="mean"></param>
 /// <param name="variance"></param>
 /// <param name="lowerBound"></param>
 /// <param name="upperBound"></param>
 public TruncatedGaussian(double mean, double variance, double lowerBound, double upperBound)
 {
     this.Gaussian = Gaussian.FromMeanAndVariance(mean, variance);
     LowerBound    = lowerBound;
     UpperBound    = upperBound;
 }