Пример #1
0
    public static double FisherCombineP(this IEnumerable<double> input)
    {
        int pCounter = 0;
        double accum = 0;
        foreach (var p in input)
        {
            pCounter++;
            accum += Math.Log(Math.Max(0.0001, p));
        }
        accum *= -2;
        var chi2cdf = new MathNet.Numerics.Distributions.ChiSquared(pCounter * 2);
        var retVal = 1 - chi2cdf.CumulativeDistribution(accum);

        return retVal;
    }
Пример #2
0
        /// <summary>
        /// From http://www.quantpsy.org/corrtest/corrtest.htm, doesn't work
        /// </summary>
        /// <param name="ra"></param>
        /// <param name="na"></param>
        /// <param name="rb"></param>
        /// <param name="nb"></param>
        /// <returns></returns>
        public static Tuple<double, double, double> FisherCompare2(double ra, int na, double rb, int nb)
        {
            var x1 = ra + 1;
            var x2 = 1 + -1 * ra;
            var y1 = rb + 1;
            var y2 = 1 + -1 * rb;

            var zz1 = 0.5 * Math.Log(x1) - Math.Log(x2);
            var zz2 = 0.5 * Math.Log(y1) - Math.Log(y2);
            var zz = (zz1 - zz2) / (Math.Sqrt(1 / (na - 3) + 1 / (nb - 3)));

            var chi = new MathNet.Numerics.Distributions.ChiSquared(1);

            var pp2 = chi.CumulativeDistribution(zz * zz);
            var pp1 = pp2 / 2;

            return Tuple.Create(zz, pp1, pp2);
        }