/**
 * A utility class for calculating descriptive statistics.
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class Statistics
{
    /**
     * Find the maximum of some data points.
     *
     * @param data  The data points
     */
    public static Ordered max(Ordered... data)
    {
        Ordered max;

        if (data == null || data.length == 0) 
            throw new IllegalArgumentException();

        if (data.length == 1) return data[0];
        
        max = data[0];        
        for (int i=1; i<data.length; i++)
        {
            if (data[i].compareTo(max) > 0) max = data[i];
        }

        return max;
    }


    /**
     * Find the minimum of some data points.
     *
     * @param data  The data points
     */
    public static Ordered min(Ordered... data)
    {
        Ordered min;

        if (data == null || data.length == 0) 
            throw new IllegalArgumentException();

        if (data.length == 1) return data[0];
        
        min = data[0];        
        for (int i=1; i<data.length; i++)
        {
            if (data[i].compareTo(min) < 0) min = data[i];
        }

        return min;
    }
}
