public MannWhitneyDistribution(double[] ranks,
[PositiveInteger] int n1, [PositiveInteger] int n2)
{
this.Ranks = ranks;
this.Samples1 = n1;
this.Samples2 = n2;
int nt = n1 + n2;
if (n1 <= 0)
{
throw new ArgumentOutOfRangeException("n1",
"The first number of samples must be positive.");
}
if (n2 <= 0)
{
throw new ArgumentOutOfRangeException("n2",
"The second number of samples must be positive.");
}
this.smallSample = (n1 <= 30 && n2 <= 30);
if (smallSample)
{
// For a small sample (< 30) the distribution is exact.
int nc = (int)Special.Binomial(nt, n1);
table = new double[nc];
int i = 0; // Consider all possible combinations of samples
foreach (double[] combination in Combinatorics.Combinations(Ranks, n1))
table[i++] = USample1(combination, Samples2);
Array.Sort(table);
}
}