Example: Ranks
In this data from Hinkley (1977) note that the fourth and sixth observations are tied and that the third and twentieth are tied.
using System;
using Imsl.Stat;
using Imsl.Math;
public class RanksEx1
{
public static void Main(String[] args)
{
double[] x = new double[]{0.77, 1.74, 0.81, 1.20, 1.95, 1.20,
0.47, 1.43, 3.37, 2.20, 3.00,
3.09, 1.51, 2.10, 0.52, 1.62,
1.31, 0.32, 0.59, 0.81, 2.81,
1.87, 1.18, 1.35, 4.75, 2.48,
0.96, 1.89, 0.90, 2.05};
PrintMatrixFormat mf = new PrintMatrixFormat();
mf.SetNoRowLabels();
mf.SetNoColumnLabels();
Ranks ranks = new Ranks();
double[] score = ranks.GetRanks(x);
new PrintMatrix("The Ranks of the Observations - " +
"Ties Averaged").Print(mf, score);
Console.Out.WriteLine();
ranks = new Ranks();
ranks.TieBreaker = Imsl.Stat.Ranks.Tie.Highest;
score = ranks.GetBlomScores(x);
new PrintMatrix("The Blom Scores of the Observations - " +
"Highest Score used in Ties").Print(mf, score);
Console.Out.WriteLine();
ranks = new Ranks();
ranks.TieBreaker = Imsl.Stat.Ranks.Tie.Lowest;
score = ranks.GetTukeyScores(x);
new PrintMatrix("The Tukey Scores of the Observations - " +
"Lowest Score used in Ties").Print(mf, score);
Console.Out.WriteLine();
ranks = new Ranks();
ranks.TieBreaker = Imsl.Stat.Ranks.Tie.Random;
Imsl.Stat.Random random = new Imsl.Stat.Random(123457);
random.Multiplier = 16807;
ranks.Random = random;
score = ranks.GetVanDerWaerdenScores(x);
new PrintMatrix("The Van Der Waerden Scores of the " +
"Observations - Ties untied by Random").Print(mf, score);
}
}
Output
The Ranks of the Observations - Ties Averaged
5
18
6.5
11.5
21
11.5
2
15
29
24
27
28
16
23
3
17
13
1
4
6.5
26
19
10
14
30
25
9
20
8
22
The Blom Scores of the Observations - Highest Score used in Ties
-1.02410618374162
0.208663745751154
-0.775546958322378
-0.294213138930921
0.472789120992267
-0.294213138930921
-1.60981606718445
-0.0414437330939966
1.60981606718445
0.775546958322378
1.17581347255003
1.36087334286719
0.0414437330939965
0.668002132269574
-1.36087334286719
0.124617407947998
-0.208663745751155
-2.04028132201041
-1.17581347255003
-0.775546958322378
1.02410618374162
0.294213138930921
-0.472789120992267
-0.124617407947998
2.04028132201041
0.892918486444395
-0.56768639112746
0.381975767696542
-0.668002132269574
0.56768639112746
The Tukey Scores of the Observations - Lowest Score used in Ties
-1.0200762327862
0.208082136154993
-0.88970115508476
-0.380874057516038
0.471389465588488
-0.380874057516038
-1.59868725959458
-0.0413298117447387
1.59868725959458
0.772935693128221
1.17060337087942
1.35372485367826
0.0413298117447388
0.665869518001049
-1.35372485367826
0.124273282084069
-0.208082136154993
-2.01450973381435
-1.17060337087942
-0.88970115508476
1.0200762327862
0.293381232121193
-0.471389465588488
-0.124273282084069
2.01450973381435
0.889701155084761
-0.565948821932863
0.380874057516038
-0.665869518001048
0.565948821932863
The Van Der Waerden Scores of the Observations - Ties untied by Random
-0.989168627340635
0.203544231532486
-0.864894358685283
-0.372289360465191
0.460494539103116
-0.286893916923039
-1.51792915959428
-0.0404405085656462
1.51792915959428
0.75272879425817
1.13097760824516
1.30015343336342
0.0404405085656462
0.649323913186466
-1.30015343336342
0.121587382750483
-0.203544231532486
-1.84859628850141
-1.13097760824516
-0.75272879425817
0.989168627340635
0.286893916923039
-0.460494539103116
-0.121587382750483
1.84859628850141
0.864894358685283
-0.552442584646774
0.372289360465191
-0.649323913186466
0.552442584646775
Link to C# source.