コード例 #1
0
        /// <summary>
        /// Creates a new Gaussian which is the ratio of two other Gaussians
        /// </summary>
        /// <param name="numerator">numerator Gaussian</param>
        /// <param name="denominator">denominator Gaussian</param>
        /// <returns>Result</returns>
        public static Gaussian operator/(Gaussian numerator, Gaussian denominator)
        {
            Gaussian result = new Gaussian();

            result.SetToRatio(numerator, denominator);
            return(result);
        }
コード例 #2
0
 /// <summary>
 /// Set this equal to numerator/denominator
 /// </summary>
 /// <param name="numerator"></param>
 /// <param name="denominator"></param>
 public void SetToRatio(TruncatedGaussian numerator, TruncatedGaussian denominator)
 {
     if (numerator.IsPointMass)
     {
         if (denominator.IsPointMass)
         {
             if (numerator.Point.Equals(denominator.Point))
             {
                 SetToUniform();
             }
             else
             {
                 throw new DivideByZeroException();
             }
         }
         else
         {
             if (denominator.LowerBound < numerator.Point && numerator.Point < denominator.UpperBound)
             {
                 Point = numerator.Point;
             }
             else
             {
                 throw new DivideByZeroException();
             }
         }
     }
     else if (denominator.IsPointMass)
     {
         throw new DivideByZeroException();
     }
     else
     {
         if (numerator.LowerBound >= denominator.LowerBound && numerator.UpperBound <= denominator.UpperBound)
         {
             LowerBound = numerator.LowerBound;
             UpperBound = numerator.UpperBound;
             Gaussian.SetToRatio(numerator.Gaussian, denominator.Gaussian);
         }
         else
         {
             throw new DivideByZeroException();
         }
     }
 }