Ejemplo n.º 1
0
 /// <summary>
 /// Sets the parameters to represent the power of a source Gamma to some exponent.
 /// </summary>
 /// <param name="dist">The source Gamma</param>
 /// <param name="exponent">The exponent</param>
 public void SetToPower(Gamma dist, double exponent)
 {
     if (dist.IsPointMass)
     {
         if (exponent == 0)
         {
             SetToUniform();
         }
         else if (exponent < 0)
         {
             throw new DivideByZeroException("The exponent is negative and the distribution is a point mass");
         }
         else
         {
             Point = dist.Point;
         }
         return;
     }
     else
     {
         if (Math.Abs(exponent) > 1e1)
         {
             Shape = (dist.Shape - 1) * exponent + 1;
         }
         else
         {
             Shape = dist.Shape * exponent + (1 - exponent);
         }
         Rate = dist.Rate * exponent;
         if (Shape > double.MaxValue || Rate > double.MaxValue)
         {
             Point = dist.GetMode();
         }
     }
 }