Package com.imsl.stat

Class Summary

java.lang.Object
com.imsl.stat.Summary
All Implemented Interfaces:
Serializable, Cloneable

public class Summary extends Object implements Serializable, Cloneable
Computes basic univariate statistics.

For the data in x. Summary computes the sample mean, variance, minimum, maximum, and ther basic statistics. It also computes confidence intervals for the mean and variance if the sample is assumed to be from a normal population.

Missing values, that is, values equal to NaN (not a number), are excluded from the computations. The sum of the weights is used only in computing the mean (of course, then the weighted mean is used in computing the central moments). The definitions of some of the statistics are given below in terms of a single variable x. The i-th datum is \(x_i\), with corresponding weight \(w_i\). If weights are not specified, the \(w_i\) are identically one. The summation in each case is over the set of valid observations, based on the presence of missing values in the data.

Number of nonmissing observations,

$$n = \sum {f_i } $$

Mean,

$$\bar x_w = \frac{{\sum {f_i w_i x_i } }}{{\sum {f_i w_i } }} $$

Variance,

$$s_w^2 = \frac{{\sum {f_i w_i \left( {x_i - \bar x_w } \right)^2 } }}{{n - 1}} $$

Skewness,

$$\frac{{\sum {f_i w_i \left( {x_i - \bar x_w } \right)^3 /n} }}{{[\sum {f_i w_i \left( {x_i - \bar x_w } \right)^2 /n]^{3/2} } }} $$

Excess or Kurtosis,

$$\frac{{\sum {f_i w_i \left( {x_i - \bar x_w } \right)^4 /n} }}{{[\sum {f_i w_i \left( {x_i - \bar x_w } \right)^2 /n]^2 } }} - 3 $$

Minimum,

$$x_{\rm min} = \min (x_i ) $$

Maximum,

$$x_{\rm max} = \max (x_i ) $$)

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new summary statistics object.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    confidenceMean(double p)
    Returns the confidence interval for the mean (assuming normality).
    double[]
    Returns the confidence interval for the variance (assuming normality).
    double
    Returns the kurtosis.
    double
    Returns the maximum.
    double
    Returns the population mean.
    double
    Returns the minimum.
    int
    Returns the number of non-missing observations.
    double
    Returns the sample standard deviation.
    double
    Returns the sample variance.
    double
    Returns the skewness.
    double
    Returns the population standard deviation.
    double
    Returns the population variance.
    static double
    kurtosis(double[] x)
    Returns the kurtosis of the given data set.
    static double
    kurtosis(double[] x, double[] weight)
    Returns the kurtosis of the given data set and associated weights.
    static double
    maximum(double[] x)
    Returns the maximum of the given data set.
    protected static int
    maximum(int[] x)
    Returns the maximum of the given data set.
    static double
    mean(double[] x)
    Returns the mean of the given data set.
    static double
    mean(double[] x, double[] weight)
    Returns the mean of the given data set with associated weights.
    static double
    median(double[] x)
    Returns the median of the given data set.
    static double
    median(double[] x, double[] weight)
    Returns the weighted median of the given data set and associated weights.
    static double
    minimum(double[] x)
    Returns the minimum of the given data set.
    protected static int
    minimum(int[] x)
    Returns the minimum of the given data set.
    static double
    mode(double[] x)
    Returns the mode of the given data set.
    static int
    Returns the number of non-missing observations in the given data set.
    static double
    quantile(double[] x, double[] weight, double alpha)
     
    static double
    Returns the sample standard deviation of the given data set.
    static double
    sampleStandardDeviation(double[] x, double[] weight)
    Returns the sample standard deviation of the given data set and associated weights.
    static double
    sampleVariance(double[] x)
    Returns the sample variance of the given data set.
    static double
    sampleVariance(double[] x, double[] weight)
    Returns the sample variance of the given data set and associated weights.
    static double
    skewness(double[] x)
    Returns the skewness of the given data set.
    static double
    skewness(double[] x, double[] weight)
    Returns the skewness of the given data set and associated weights.
    static double
    standardDeviation(double[] x)
    Returns the population standard deviation of the given data set.
    static double
    standardDeviation(double[] x, double[] weight)
    Returns the population standard deviation of the given data set and associated weights.
    void
    update(double x)
    Adds an observation to the Summary object.
    void
    update(double[] x)
    Adds a set of observations to the Summary object.
    void
    update(double[] x, double[] weight)
    Adds a set of observations and associated weights to the Summary object.
    void
    update(double x, double weight)
    Adds an observation and associated weight to the Summary object.
    static double
    variance(double[] x)
    Returns the population variance of the given data set.
    static double
    variance(double[] x, double[] weight)
    Returns the population variance of the given data set and associated weights.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Summary

      public Summary()
      Constructs a new summary statistics object.
  • Method Details

    • update

      public void update(double x)
      Adds an observation to the Summary object.
      Parameters:
      x - a double, the data observation to be added
    • update

      public void update(double x, double weight)
      Adds an observation and associated weight to the Summary object.
      Parameters:
      x - a double, the data observation to be added
      weight - a double, the weight associated with the observation
    • update

      public void update(double[] x)
      Adds a set of observations to the Summary object.
      Parameters:
      x - a double array of data observations to be added
    • update

      public void update(double[] x, double[] weight)
      Adds a set of observations and associated weights to the Summary object.
      Parameters:
      x - a double array of data observations to be added
      weight - a double array of weights associated with the observations
    • getNumberOfObservations

      public int getNumberOfObservations()
      Returns the number of non-missing observations.
      Returns:
      an int, the number of non-missing observations in the Summary object.
    • getMinimum

      public double getMinimum()
      Returns the minimum.
      Returns:
      a double representing the minimum
    • getMaximum

      public double getMaximum()
      Returns the maximum.
      Returns:
      a double representing the maximum
    • getMean

      public double getMean()
      Returns the population mean.
      Returns:
      a double representing the population mean
    • getVariance

      public double getVariance()
      Returns the population variance.
      Returns:
      a double representing the population variance
    • getSampleVariance

      public double getSampleVariance()
      Returns the sample variance.
      Returns:
      a double representing the sample variance
    • getStandardDeviation

      public double getStandardDeviation()
      Returns the population standard deviation.
      Returns:
      a double representing the population standard deviation
    • getSampleStandardDeviation

      public double getSampleStandardDeviation()
      Returns the sample standard deviation.
      Returns:
      a double representing the sample standard deviation
    • getSkewness

      public double getSkewness()
      Returns the skewness.
      Returns:
      a double representing the skewness
    • getKurtosis

      public double getKurtosis()
      Returns the kurtosis.
      Returns:
      a double representing the kurtosis
    • confidenceMean

      public double[] confidenceMean(double p)
      Returns the confidence interval for the mean (assuming normality).
      Parameters:
      p - a double, the confidence level desired, usually 0.90, 0.95 or 0.99.
      Returns:
      a double array of length 2 which contains the lower and upper confidence limits for the mean
    • confidenceVariance

      public double[] confidenceVariance(double p)
      Returns the confidence interval for the variance (assuming normality).
      Parameters:
      p - a double, the confidence level desired, usually 0.90, 0.95 or 0.99.
      Returns:
      a double array of length 2 which contains the lower and upper confidence limits for the variance
    • minimum

      public static double minimum(double[] x)
      Returns the minimum of the given data set.
      Parameters:
      x - a double array containing the data set whose minimum is to be found.
      Returns:
      a double, the minimum of the given data set.
    • numberOfObservations

      public static int numberOfObservations(double[] x)
      Returns the number of non-missing observations in the given data set.
      Parameters:
      x - a double array containing the data set.
      Returns:
      an int, the number of non-missing observations in the given data set.
    • minimum

      protected static int minimum(int[] x)
      Returns the minimum of the given data set.
      Parameters:
      x - an int array containing the data set whose minimum is to be found
      Returns:
      an int, the minimum of the given data set
    • maximum

      public static double maximum(double[] x)
      Returns the maximum of the given data set.
      Parameters:
      x - a double array containing the data set whose maximum is to be found
      Returns:
      a double, the maximum of the given data set
    • maximum

      protected static int maximum(int[] x)
      Returns the maximum of the given data set.
      Parameters:
      x - an int array containing the data set whose maximum is to be found
      Returns:
      an int, the maximum of the given data set
    • mean

      public static double mean(double[] x)
      Returns the mean of the given data set.
      Parameters:
      x - a double array containing the data set whose mean is to be found
      Returns:
      a double, the mean of the given data set
    • mean

      public static double mean(double[] x, double[] weight)
      Returns the mean of the given data set with associated weights.
      Parameters:
      x - a double array containing the data set whose mean is to be found
      weight - a double array containing the weights associated with the data points x
      Returns:
      a double, the mean of the given data set
    • variance

      public static double variance(double[] x)
      Returns the population variance of the given data set.
      Parameters:
      x - a double array containing the data set whose population variance is to be found
      Returns:
      a double, the population variance of the given data set
    • variance

      public static double variance(double[] x, double[] weight)
      Returns the population variance of the given data set and associated weights.
      Parameters:
      x - a double array containing the data set whose population variance is to be found
      weight - a double array containing the weights associated with the data points x
      Returns:
      a double, the population variance of the given data set
    • sampleVariance

      public static double sampleVariance(double[] x)
      Returns the sample variance of the given data set.
      Parameters:
      x - a double array containing the data set whose sample variance is to be found
      Returns:
      a double, the sample variance of the given data set
    • sampleVariance

      public static double sampleVariance(double[] x, double[] weight)
      Returns the sample variance of the given data set and associated weights.
      Parameters:
      x - a double array containing the data set whose sample variance is to be found
      weight - a double array containing the weights associated with the data points x
      Returns:
      a double, the sample variance of the given data set
    • standardDeviation

      public static double standardDeviation(double[] x)
      Returns the population standard deviation of the given data set.
      Parameters:
      x - a double array containing the data set whose standard deviation is to be found
      Returns:
      a double, the population standard deviation of the given data set
    • standardDeviation

      public static double standardDeviation(double[] x, double[] weight)
      Returns the population standard deviation of the given data set and associated weights.
      Parameters:
      x - a double array containing the data set whose standard deviation is to be found
      weight - a double array containing the weights associated with the data points x
      Returns:
      a double, the population standard deviation of the given data set
    • sampleStandardDeviation

      public static double sampleStandardDeviation(double[] x)
      Returns the sample standard deviation of the given data set.
      Parameters:
      x - a double array containing the data set whose sample standard deviation is to be found
      Returns:
      a double, the sample standard deviation of the given data set
    • sampleStandardDeviation

      public static double sampleStandardDeviation(double[] x, double[] weight)
      Returns the sample standard deviation of the given data set and associated weights.
      Parameters:
      x - a double array containing the data set whose sample standard deviation is to be found
      weight - a double array containing the weights associated with the data points x.
      Returns:
      a double, the sample standard deviation of the given data set
    • skewness

      public static double skewness(double[] x)
      Returns the skewness of the given data set.
      Parameters:
      x - a double array containing the data set whose skewness is to be found
      Returns:
      a double, the skewness of the given data set
    • skewness

      public static double skewness(double[] x, double[] weight)
      Returns the skewness of the given data set and associated weights.
      Parameters:
      x - a double array containing the data set whose skewness is to be found
      weight - a double array containing the weights associated with the data points x
      Returns:
      a double, the skewness of the given data set
    • kurtosis

      public static double kurtosis(double[] x)
      Returns the kurtosis of the given data set.
      Parameters:
      x - a double array containing the data set whose kurtosis is to be found
      Returns:
      a double, the kurtosis of the given data set
    • kurtosis

      public static double kurtosis(double[] x, double[] weight)
      Returns the kurtosis of the given data set and associated weights.
      Parameters:
      x - a double array containing the data set whose kurtosis is to be found
      weight - a double array containing the weights associated with the data points x
      Returns:
      a double, the kurtosis of the given data set
    • median

      public static double median(double[] x, double[] weight)
      Returns the weighted median of the given data set and associated weights.
      Parameters:
      x - a double array containing the data set whose median is to be found
      weight - a double array containing the weights associated with the data
      Returns:
      a double, the weighted median of the given data set
    • quantile

      public static double quantile(double[] x, double[] weight, double alpha)
    • median

      public static double median(double[] x)
      Returns the median of the given data set.
      Parameters:
      x - a double array containing the data set whose median is to be found
      Returns:
      a double, the median of the given data set
    • mode

      public static double mode(double[] x)
      Returns the mode of the given data set. Ties are broken at random.
      Parameters:
      x - a double array containing the data set whose mode is to be found
      Returns:
      a double, the mode of the given data set