Accord.Statistics.Distributions.Univariate.MannWhitneyDistribution.UMinimum C# (CSharp) Method

UMinimum() public static method

Gets the Mann-Whitney's U statistic for the smaller sample.
public static UMinimum ( double ranks, int n1, int n2 ) : double
ranks double
n1 int
n2 int
return double
        public static double UMinimum(double[] ranks, int n1, int n2)
        {
            // Split the rankings back and sum
            double[] rank1 = ranks.Get(0, n1 - 1);
            double[] rank2 = ranks.Get(n1, n1 + n2 - 1);

            double t1 = rank1.Sum();
            double t2 = rank2.Sum();

            double t1max = n1 * n2 + (n1 * (n1 + 1)) / 2.0;
            double t2max = n1 * n2 + (n2 * (n2 + 1)) / 2.0;

            double u1 = t1max - t1;
            double u2 = t2max - t2;

            return Math.Min(u1, u2);
        }