C#、数値計算 - Chisq分布の計算方法とソースコード

 

システムを使用する;

namespace Legalsoft.Truffer
{     public class Chisqdist : Gamma     {         private double nu { get; 設定; プライベート         ダブルファク{取得; 設定; }



        public Chisqdist(double nnu)
        {             this.nu = nnu;             if (nu <= 0.0)             {                 throw new Exception("bad nu in Chisqdist");             fac = 0.693147180559945309 * ( 0.5             * nu) + Globals.gammln(0.5 * nu);         }






        public double p(double x2)
        {             if (x2 <= 0.0)             {                 throw new Exception("bad x2 in Chisqdist");             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("bad x2 in Chisqdist");             gammp(0.5 * nu, 0.5 * x2) を返します             。         }





        public double invcdf(double p)
        {             if (p < 0.0 || p >= 1.0)             {                 throw new Exception("bad p in Chisqdist");             2.0 * invgammp(p, 0.5 * nu) を返します             。         } }     }







おすすめ

転載: blog.csdn.net/beijinghorn/article/details/131670422