zoukankan      html  css  js  c++  java
  • Anderson Darling 检验

     http://en.wikipedia.org/wiki/Anderson-Darling_test

    /// <summary>
    /// AD检验
    /// </summary>
    /// <param name="stats"></param>
    /// <returns>P值</returns>
    public static double ad_test(double[] stats)
    {
    //check IsNaN

    int n = stats.Length;
    List<double> x = new List<double>(stats);
    x.Sort();
    var normal = new NormalDistribution();
    normal.EstimateDistributionParameters(stats);
    double sum = 0;

    for (int index =0; index < x.Count; index++)
    {
    double stat = x[index];
    double stat1 = x[n -1- index];
    var sz = (((2*(index+1.0)) - 1)/n)*
    (Math.Log(normal.CumulativeDistribution(stat)) +
    Math.Log(1 - normal.CumulativeDistribution(stat1)));

    sum +=sz ;
    }

    double AD2 = -n - sum;

    double AD2a = AD2*(1 + 0.75/n + 2.25/(n*n)); //correction factor for small sample sizes: case normal
    double P = 0;

    if (AD2a >= 0.00 && AD2a < 0.200)
    {
    P = 1 - Math.Exp(-13.436 + 101.14*AD2a - 223.73*AD2a*AD2a);
    }
    else if (AD2a >= 0.200 && AD2a < 0.340)
    {
    P = 1 - Math.Exp(-8.318 + 42.796*AD2a - 59.938*AD2a*AD2a);
    }
    else if (AD2a >= 0.340 && AD2a < 0.600)
    {
    P = Math.Exp(0.9177 - 4.279*AD2a - 1.38*AD2a*AD2a);
    }
    else
    {
    P = Math.Exp(1.2937 - 5.709*AD2a + 0.0186*AD2a*AD2a);
    }



    return P;
    }

    http://kwok.io/
  • 相关阅读:
    Linux下文件的压缩和解压
    Env: Linux下Source Insight安装
    [uart]2.tty和uart的函数调用流程
    [uart]stty命令使用
    腾讯云的云数据库MYSQL配置
    MySQL分支Percona
    MYSQL的历史
    MYSQL的价格
    mysql之event
    Linux下设置网卡静态ip
  • 原文地址:https://www.cnblogs.com/yuzukwok/p/3121477.html
Copyright © 2011-2022 走看看