Example: Empirical Quantiles

In this example, five empirical quantiles from a sample of size 30 are obtained. Notice that the 0.5 quantile corresponds to the sample median. The data are from Hinkley (1977) and Velleman and Hoaglin (1981). They are the measurements (in inches) of precipitation in Minneapolis/St. Paul during the month of March for 30 consecutive years.
using System;
using Imsl.Stat;

public class EmpiricalQuantilesEx1
{
    public static void  Main(String[] args)
    {
        double[]  x = {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};
        double[] qProp = {0.01, 0.5, 0.90, 0.95, 0.99};
        EmpiricalQuantiles eq = new EmpiricalQuantiles(x, qProp);
            
        double[] Q = eq.GetQ();
        double[] XLo = eq.GetXLo();
        double[] XHi = eq.GetXHi();

        Console.WriteLine("               Smaller        Empirical        Larger");
        Console.WriteLine(" Quantile       Datum          Quantile         Datum");
        for (int i=0; i < qProp.Length; i++)
            Console.WriteLine("  {0}\t\t{1}\t\t{2}\t\t{3}", 
                qProp[i], XLo[i], Q[i], XHi[i]);
    }
}

Output

               Smaller        Empirical        Larger
 Quantile       Datum          Quantile         Datum
  0.01		0.32		0.32		0.32
  0.5		1.43		1.47		1.51
  0.9		3		3.081		3.09
  0.95		3.37		3.991		4.75
  0.99		4.75		4.75		4.75

Link to C# source.