コード例 #1
0
        /// <summary>
        /// Raises a distribution to a power.
        /// </summary>
        /// <param name="dist">The distribution.</param>
        /// <param name="exponent">The power to raise to.</param>
        /// <returns><paramref name="dist"/> raised to power <paramref name="exponent"/>.</returns>
        public static Gaussian operator^(Gaussian dist, double exponent)
        {
            Gaussian result = new Gaussian();

            result.SetToPower(dist, exponent);
            return(result);
        }
コード例 #2
0
 /// <summary>
 /// Set this equal to (dist)^exponent
 /// </summary>
 /// <param name="dist"></param>
 /// <param name="exponent"></param>
 public void SetToPower(TruncatedGaussian dist, double exponent)
 {
     if (exponent == 0)
     {
         SetToUniform();
     }
     else
     {
         if (exponent < 0 && !(double.IsNegativeInfinity(dist.LowerBound) && double.IsPositiveInfinity(dist.UpperBound)))
         {
             throw new DivideByZeroException("The exponent is negative and the bounds are finite");
         }
         LowerBound = dist.LowerBound;
         UpperBound = dist.UpperBound;
         Gaussian.SetToPower(dist.Gaussian, exponent);
     }
 }