C#, 수치 계산 - Chisq 분포의 계산 방법 및 소스 코드

 

시스템 사용;

네임스페이스 Legalsoft.Truffer
{     공개 클래스 Chisqdist : 감마     {         개인 더블 nu { get; 세트; }         개인 이중 팩트 { 가져오기; 세트; }



        공개 Chisqdist(double nnu)
        {             this.nu = nnu;             if (nu <= 0.0)             {                 throw new Exception("Chisqdist의 나쁜 nu");             }             fac = 0.693147180559945309 * (0.5 * nu) + Globals.gammln(0.5 * nu);         }






        public double p(double x2)
        {             if (x2 <= 0.0)             {                 throw new Exception("Chisqdist의 잘못된 x2");             }             return Math.Exp(-0.5 * (x2 - (nu - 2.0) * Math.Log(x2)) - fac);         }





        public double cdf(double x2)
        {             if (x2 < 0.0)             {                 throw new Exception("Chisqdist의 잘못된 x2");             }             gammp(0.5 * nu, 0.5 * x2)를 반환합니다.         }





        public double invcdf(double p)
        {             if (p < 0.0 || p >= 1.0)             {                 throw new Exception("Chisqdist의 잘못된 p");             }             2.0 * invgammp(p, 0.5 * nu)를 반환합니다.         } }     }







Acho que você gosta

Origin blog.csdn.net/beijinghorn/article/details/131670422
Recomendado
Clasificación