com.hyperion.essbase.calculator
Class Statistics

java.lang.Object
  |
  +--com.hyperion.essbase.calculator.Statistics
All Implemented Interfaces:
CalculatorConstants

public final class Statistics
extends java.lang.Object
implements CalculatorConstants

This class provides a set of simple statistical routines. Some of them are present native in Essbase as well and some are not. Contains:


Fields inherited from interface com.hyperion.essbase.calculator.CalculatorConstants
MISSG, MISSING, MISSING_BYTE, MISSING_CHAR, MISSING_DOUBLE, MISSING_FLOAT, MISSING_INT, MISSING_LONG, MISSING_SHORT, SKIPBOTH, SKIPMISSG, SKIPNONE, SKIPZERO
 
Constructor Summary
Statistics()
           
 
Method Summary
static double avg(double[] data)
          Computes the average value of a given sequence.
static double avg(double[] data, double[] weights)
          Computes weighted average of a given sequence.
static double avg(int skip, double[] data)
          Computes the average value of a given sequence (with prescribed skip directive).
static double avg(int skip, double[] data, double[] weights)
          Computes weighted average value of a given sequence (with prescribed skip directive).
static double correlation(double[] x, double[] y)
          Computes correlation between two sequences If a missing value is encountered in either of the sequences, the corresponding position is skipped in both of them.
static double correlation(double[] x, double[] y, double[] weights)
          Computes weighted correlation between two sequences If a missing value is encountered in either of the sequences, the corresponding position is skipped in both of them.
static int count(double[] data)
          Computes count of non-missing values in a given sequence.
static int count(int skip, double[] data)
          Computes count of a given sequence (with prescribed skip directive).
static double covariance(double[] x, double[] y)
          Computes covariance between two sequences.
static double covariance(double[] x, double[] y, double[] weights)
          Computes weighted covariance between two sequences If a missing value is encountered in either of the sequences, the corresponding position is skipped in both of them.
static double geomean(double[] data)
          Computes the geometric average value of a given sequence.
static double geomean(double[] data, double[] weights)
          Computes weighted geometric average of a given sequence.
static double harmean(double[] data)
          Computes harmonic mean of a given sequence.
static double harmean(double[] data, double[] weights)
          Computes weighted harmonic mean of a given sequence.
static double kurt(double[] data)
          Computes kurtosis of a sequence.
static double kurt(double[] data, double[] weights)
          Computes weighted kurtosis of a sequence.
static double max(double[] data)
          Computes maximum value of given sequence.
static double median(double[] data)
          Computes median of a sequence.
static double min(double[] data)
          Computes minimum value of given sequence.
static double mode(double[] data)
          Computes mode of a sequence.
static double percentile(double percent, double[] data)
          Computes percentile of a sequence.
static double percentile(double percent, int size, double[] data)
          Computes percentile of a part of a sequence.
static double product(double[] data)
          Computes product of a given sequence.
static double product(double[] data, double[] weights)
          Computes weighted product of a given sequence.
static double quartile(int quart, double[] data)
          Computes quartile of a sequence.
static double rank(double value, double[] data)
          Computes rank of a value relative to a given sequence.
static double skew(double[] data)
          Computes skewness of a sequence.
static double skew(double[] data, double[] weights)
          Computes weighted skewness of a sequence.
static double stdev(double[] data)
          Computes standard deviation of a given sequence.
static double stdev(double[] data, double[] weights)
          Computes weighted standard deviation of a given sequence.
static double stdev(int skip, double[] data)
          Computes standard deviation of a given sequence (with prescribed skip directive).
static double stdev(int skip, double[] data, double[] weights)
          Computes weighted standard deviation of a given sequence (with prescribed skip directive).
static double stdevp(double[] data)
          Computes stdevp of a given sequence.
static double stdevp(double[] data, double[] weights)
          Computes weighted standard deviation of a given sequence.
static double stdevp(int skip, double[] data)
          Computes stdevp of a given sequence (with prescribed skip directive).
static double stdevp(int skip, double[] data, double[] weights)
          Computes weighted stdevp value of a given sequence (with prescribed skip directive).
static double sum(double[] data)
          Computes sum of a given sequence.
static double sum(double[] data, double[] weights)
          Computes weighted sum of a given sequence.
static double var(double[] data)
          Computes variance of a given sequence.
static double var(double[] data, double[] weights)
          Computes weighted variance of a given sequence.
static double var(int skip, double[] data)
          Computes variance of a given sequence (with prescribed skip directive).
static double var(int skip, double[] data, double[] weights)
          Computes weighted variance of a given sequence (with prescribed skip directive).
static double varp(double[] data)
          Computes variancep of a given sequence.
static double varp(double[] data, double[] weights)
          Computes weighted varp of a given sequence.
static double varp(int skip, double[] data)
          Computes variancep of a given sequence (with prescribed skip directive).
static double varp(int skip, double[] data, double[] weights)
          Computes weighted varp of a given sequence (with prescribed skip directive).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Statistics

public Statistics()
Method Detail

avg

public static double avg(double[] data)
Computes the average value of a given sequence. Missing values are ignored.
Parameters:
data - data array
Returns:
average of the data

avg

public static double avg(double[] data,
                         double[] weights)
Computes weighted average of a given sequence. Missing values are ignored
Parameters:
data - data array
weights - weights
Returns:
weighted average of the data

avg

public static double avg(int skip,
                         double[] data)
Computes the average value of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
Returns:
average of the data

avg

public static double avg(int skip,
                         double[] data,
                         double[] weights)
Computes weighted average value of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
weights - weights
Returns:
weighted average of the data

correlation

public static double correlation(double[] x,
                                 double[] y)
Computes correlation between two sequences If a missing value is encountered in either of the sequences, the corresponding position is skipped in both of them.
Parameters:
x - first array
y - second array
Returns:
correlation

correlation

public static double correlation(double[] x,
                                 double[] y,
                                 double[] weights)
Computes weighted correlation between two sequences If a missing value is encountered in either of the sequences, the corresponding position is skipped in both of them.
Parameters:
x - first array
y - second array
Returns:
correlation

count

public static int count(double[] data)
Computes count of non-missing values in a given sequence.
Parameters:
data - data array
Returns:
count of the non-missing data

count

public static int count(int skip,
                        double[] data)
Computes count of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
Returns:
count of the data

covariance

public static double covariance(double[] x,
                                double[] y)
Computes covariance between two sequences. If a missing value is encountered in either of the sequences, the corresponding position is skipped in both of them.
Parameters:
x - first array
y - second array
Returns:
covariance

covariance

public static double covariance(double[] x,
                                double[] y,
                                double[] weights)
Computes weighted covariance between two sequences If a missing value is encountered in either of the sequences, the corresponding position is skipped in both of them.
Parameters:
x - first array
y - second array
Returns:
correlation

geomean

public static double geomean(double[] data)
Computes the geometric average value of a given sequence. Missing values are ignored.
Parameters:
data - data array
Returns:
average of the data

geomean

public static double geomean(double[] data,
                             double[] weights)
Computes weighted geometric average of a given sequence. Missing values are ignored
Parameters:
data - data array
weights - weights
Returns:
weighted average of the data

harmean

public static double harmean(double[] data)
Computes harmonic mean of a given sequence. Missing values are ignored.
Parameters:
data - data array
Returns:
harmonic mean of the data

harmean

public static double harmean(double[] data,
                             double[] weights)
Computes weighted harmonic mean of a given sequence. Missing values are ignored
Parameters:
data - data array
weights - weights
Returns:
weighted harmonic mean of the data

kurt

public static double kurt(double[] data)
Computes kurtosis of a sequence. Missing values are skipped
Parameters:
data - data array
Returns:
kurtosis of the sequence

kurt

public static double kurt(double[] data,
                          double[] weights)
Computes weighted kurtosis of a sequence. Missing values are ignored
Parameters:
x - data array
Returns:
kurtosis of the sequence

max

public static double max(double[] data)
Computes maximum value of given sequence. Missing values are ignored.
Parameters:
data - data array
Returns:
maximum value in the array

median

public static double median(double[] data)
Computes median of a sequence. Missing values are ignored
Parameters:
data - data array

min

public static double min(double[] data)
Computes minimum value of given sequence. Missing values are ignored
Parameters:
data - data array
Returns:
minimum value in the array

mode

public static double mode(double[] data)
Computes mode of a sequence. Missing values are ignored
Parameters:
data - array of data
Returns:
mode of the sequence

percentile

public static double percentile(double percent,
                                double[] data)
Computes percentile of a sequence. Missing values are ignored
Parameters:
percent - percent value
data - double array

percentile

public static double percentile(double percent,
                                int size,
                                double[] data)
Computes percentile of a part of a sequence. Missing values are ignored
Parameters:
percent - percent value
size - size to use
data - data array

product

public static double product(double[] data)
Computes product of a given sequence. Missing values are ignored (treated as 0)
Parameters:
data - data array
Returns:
product of the data

product

public static double product(double[] data,
                             double[] weights)
Computes weighted product of a given sequence. Missing values are ignored (treated as 0)
Parameters:
data - data array
weights - weights
Returns:
weighted product of the data

quartile

public static double quartile(int quart,
                              double[] data)
Computes quartile of a sequence. Missing values are ignored
Parameters:
quart - indicates which value to return Possible values are:
  • 0 - return minimum
  • 1 - return 25% percentile
  • 2 - return median
  • 3 - return 75% percentile
  • 4 - return maximum
data - double array

rank

public static double rank(double value,
                          double[] data)
Computes rank of a value relative to a given sequence. Missing elements in the sequence are ignored. Rank is 1-based. Missing value is not ranked.
Parameters:
value - value to be ranked
data - array of data
Returns:
rank in the sequence as a double

skew

public static double skew(double[] data)
Computes skewness of a sequence. Missing values are skipped
Parameters:
data - data array
Returns:
scewness of the sequence

skew

public static double skew(double[] data,
                          double[] weights)
Computes weighted skewness of a sequence. Missing values are ignored
Parameters:
data - data array
Returns:
skewness of the sequence

stdev

public static double stdev(double[] data)
Computes standard deviation of a given sequence. Missing values are ignored
Parameters:
data - data array
Returns:
stdev of the data

stdev

public static double stdev(double[] data,
                           double[] weights)
Computes weighted standard deviation of a given sequence. Missing values are ignored
Parameters:
data - data array
weights - weights
Returns:
weighted standard deviation of the data (without taking missing values into account)

stdev

public static double stdev(int skip,
                           double[] data)
Computes standard deviation of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
Returns:
standard deviation of the data

stdev

public static double stdev(int skip,
                           double[] data,
                           double[] weights)
Computes weighted standard deviation of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
weights - weights
Returns:
weighted standard deviation of the data

stdevp

public static double stdevp(double[] data)
Computes stdevp of a given sequence. Missing values are ignored
Parameters:
data - data array
Returns:
stdevp of the data

stdevp

public static double stdevp(double[] data,
                            double[] weights)
Computes weighted standard deviation of a given sequence. Missing values are ignored
Parameters:
data - data array
weights - weights
Returns:
weighted standard deviation of the data

stdevp

public static double stdevp(int skip,
                            double[] data)
Computes stdevp of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
Returns:
stdevp of the data

stdevp

public static double stdevp(int skip,
                            double[] data,
                            double[] weights)
Computes weighted stdevp value of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
weights - weights
Returns:
weighted stdevp of the data

sum

public static double sum(double[] data)
Computes sum of a given sequence. Missing values are ignored (treated as 0)
Parameters:
data - data array
Returns:
sum of the data

sum

public static double sum(double[] data,
                         double[] weights)
Computes weighted sum of a given sequence. Missing values are ignored (treated as 0)
Parameters:
data - data array
weights - weights
Returns:
weighted sum of the data

var

public static double var(double[] data)
Computes variance of a given sequence. Missing values are ignored
Parameters:
data - data array
Returns:
variance of the data

var

public static double var(double[] data,
                         double[] weights)
Computes weighted variance of a given sequence. Missing values are ignored
Parameters:
data - data array
weights - weights
Returns:
weighted variance of the data

var

public static double var(int skip,
                         double[] data)
Computes variance of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
Returns:
variance of the data

var

public static double var(int skip,
                         double[] data,
                         double[] weights)
Computes weighted variance of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
weights - weights
Returns:
weighted variance of the data

varp

public static double varp(double[] data)
Computes variancep of a given sequence. Missing values are ignored
Parameters:
data - data array
Returns:
variancep of the data

varp

public static double varp(double[] data,
                          double[] weights)
Computes weighted varp of a given sequence. Missing values are ignored
Parameters:
data - data array
weights - weights
Returns:
weighted varp of the data

varp

public static double varp(int skip,
                          double[] data)
Computes variancep of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
Returns:
variancep of the data

varp

public static double varp(int skip,
                          double[] data,
                          double[] weights)
Computes weighted varp of a given sequence (with prescribed skip directive).
Parameters:
skip - skip instruction; possible values are
  • SKIPNONE - nothing skipped
  • SKIPZERO - zeros skipped
  • SKIPMISSG - missing values skipped
  • SKIPBOTH - skip both zeros and missing values
(defined in CalculatorConstants interface)
data - data array
weights - weights
Returns:
weighted varp of the data