public class ChiSquareDistribution : GammaDistribution
{
public double DegreesOfFreedom => 2.0 * base.ShapeParameter;
public static double DistributionFunction(double x, int degreesOfFreedom)
{
if (degreesOfFreedom <= 0)
{
ThrowException.ArgumentOutOfRange("degreesOfFreedom");
}
if (x <= 0.0)
{
return 0.0;
}
return GammaFunctions.RegularizedGammaP(0.5 * (double)degreesOfFreedom, 0.5 * x);
}
public static double InverseDistributionFunction(double probability, double degreesOfFreedom)
{
if (probability < 0.0 || probability > 1.0)
{
ThrowException.ArgumentOutOfRange("probability");
}
if (degreesOfFreedom <= 0.0)
{
ThrowException.ArgumentOutOfRange("degreesOfFreedom");
}
return new ChiSquareDistribution(degreesOfFreedom).InverseDistributionFunction(probability);
}
public new static double GetRandomVariate(System.Random random, double degreesOfFreedom)
{
if (random == null)
{
ThrowException.ArgumentNull("random");
}
if (degreesOfFreedom <= 0.0)
{
ThrowException.ArgumentOutOfRange("degreesOfFreedom");
}
return GammaDistribution.GetRandomVariate(random, degreesOfFreedom / 2.0, 2.0);
}
public ChiSquareDistribution(double degreesOfFreedom)
: base(degreesOfFreedom / 2.0, 2.0)
{
}
}
如果对您有帮忙,非常感谢您支持一下创造者的付出!
感谢支持技术分享,请扫码点赞支持:
技术合作交流qq:2401315930