|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.math.DoubleArrayMath
ptolemy.math.DoubleArrayStat
This class provides a library for statistical operations on arrays of doubles. Unless explicitly noted otherwise, all array arguments are assumed to be non-null. If a null array is passed to a method, a NullPointerException will be thrown in the method or called methods.
| Red (ctsay) |
| Yellow (ctsay) |
| Constructor Summary | |
protected |
DoubleArrayStat()
|
| Method Summary | |
protected static int |
_nonZeroLength(double[] array,
java.lang.String methodName)
Throw an exception if the array is null or length 0. |
static double[] |
autoCorrelation(double[] x,
int N,
int startLag,
int endLag)
Return a new array that is the auto-correlation of the argument array, starting and ending at user-specified lag values. |
static double |
autoCorrelationAt(double[] x,
int N,
int lag)
Return the auto-correlation of an array at a certain lag value, summing over a certain number of samples defined by : Rxx[d] = sum of i = 0 to N - 1 of x[i] * x[i + d] N must be non-negative, but large numbers are ok because this routine will not overrun reading of the arrays. |
static double[] |
crossCorrelation(double[] x,
double[] y,
int N,
int startLag,
int endLag)
Return a new array that is the cross-correlation of the two argument arrays, starting and ending at user-specified lag values. |
static double |
crossCorrelationAt(double[] x,
double[] y,
int N,
int lag)
Return the cross-correlation of two arrays at a certain lag value, defined by : Rxy[d] = sum of i = 0 to N - 1 of x[i] * y[i + d] |
static double |
entropy(double[] p)
Given an array of probabilities, treated as a probability mass function (pmf), calculate the entropy (in bits). |
static double |
geometricMean(double[] array)
Return the geometric mean of the elements in the array. |
static double |
max(double[] array)
Return the maximum value in the array. |
static java.lang.Object[] |
maxAndIndex(double[] array)
Return the maximum value of the array and the index at which the maximum occurs in the array. |
static double |
mean(double[] array)
Return the arithmetic mean of the elements in the array. |
static double |
min(double[] array)
Return the minimum value in the array. |
static java.lang.Object[] |
minAndIndex(double[] array)
Return the minimum value of the array and the index at which the minimum occurs in the array. |
static double |
productOfElements(double[] array)
Return the product of all of the elements in the array. |
static double[] |
randomBernoulli(double p,
int N)
Return a new array of Bernoulli random variables with a given probability of success p. |
static double[] |
randomExponential(double lambda,
int N)
Return a new array of exponentially distributed doubles with parameter lambda. |
static double[] |
randomGaussian(double mean,
double standardDeviation,
int N)
Return a new array of Gaussian distributed doubles with a given mean and standard deviation. |
static double[] |
randomPoisson(double mean,
int N)
Return a new array of Poisson random variables (as doubles) with a given mean. |
static double[] |
randomUniform(double a,
double b,
int N)
Return a new array of uniformly distributed doubles ranging from a to b. |
static double |
relativeEntropy(double[] p,
double[] q)
Given two array's of probabilities, calculate the relative entropy aka Kullback Leibler distance, D(p || q), (in bits) between the two probability mass functions. |
static double |
standardDeviation(double[] array)
Return the standard deviation of the elements in the array. |
static double |
standardDeviation(double[] array,
boolean sample)
Return the standard deviation of the elements in the array. |
static double |
sumOfElements(double[] array)
Return the sum of all of the elements in the array. |
static double |
variance(double[] array)
Return the variance of the elements in the array, assuming sufficient statistics. |
static double |
variance(double[] array,
boolean sample)
Return the variance of the elements in the array, assuming sufficient statistics. |
| Methods inherited from class ptolemy.math.DoubleArrayMath |
_commonLength, add, add, allocCopy, append, append, applyBinaryOperation, applyBinaryOperation, applyBinaryOperation, applyUnaryOperation, divide, divideElements, dotProduct, l2norm, limit, modulo, multiply, multiply, negative, normalize, padMiddle, resize, resize, scale, subtract, sum, sumOfSquares, toComplexArray, toFloatArray, toIntegerArray, toLongArray, toString, toString, within, within |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected DoubleArrayStat()
| Method Detail |
public static final double[] autoCorrelation(double[] x,
int N,
int startLag,
int endLag)
x - An array of doubles.N - An integer indicating the number of samples to sum over.startLag - An int indicating at which lag to start (may be
negative).endLag - An int indicating at which lag to end.
public static double autoCorrelationAt(double[] x,
int N,
int lag)
x - An array of doubles.N - An integer indicating the number of samples to sum over.lag - An integer indicating the lag value (may be negative).
public static final double[] crossCorrelation(double[] x,
double[] y,
int N,
int startLag,
int endLag)
x - The first array of doubles.y - The second array of doubles.N - An integer indicating the number of samples to sum over.startLag - An int indicating at which lag to start (may be
negative).endLag - An int indicating at which lag to end.
public static double crossCorrelationAt(double[] x,
double[] y,
int N,
int lag)
x - The first array of doubles.y - The second array of doubles.N - An integer indicating the number of samples to sum over.
This must be non-negative, but large numbers are ok because this
routine will not overrun reading of the arrays.lag - An integer indicating the lag value (may be negative).
public static final double entropy(double[] p)
H(p) = - sum (p[x] * log2(p[x]))
The entropy is always non-negative. Throw an IllegalArgumentException if the length of the array is 0, or a negative probability is encountered.
public static final double geometricMean(double[] array)
array - An array of doubles.
public static final double max(double[] array)
public static final java.lang.Object[] maxAndIndex(double[] array)
array - An array of doubles.
public static final double mean(double[] array)
public static final double min(double[] array)
public static final java.lang.Object[] minAndIndex(double[] array)
array - An array of doubles.
public static final double productOfElements(double[] array)
public static final double[] randomBernoulli(double p,
int N)
public static final double[] randomExponential(double lambda,
int N)
public static final double[] randomGaussian(double mean,
double standardDeviation,
int N)
public static final double[] randomPoisson(double mean,
int N)
public static double[] randomUniform(double a,
double b,
int N)
a - A double indicating the lower bound.b - A double indicating the upper bound.N - An int indicating how many elements to generate.
public static final double relativeEntropy(double[] p,
double[] q)
D(p||q) = - sum (p[x] * log2(p[x]/q[x]))
Throw an IllegalArgumentException if either array has length 0. If the two arrays do not have the same length, throw an IllegalArgumentException.
p - An array of doubles representing the first pmf, p.q - An array of doubles representing the second pmf, q.
public static double standardDeviation(double[] array)
public static double standardDeviation(double[] array,
boolean sample)
stdDev = sqrt(variance)
The sample standard deviation is computed as follows
stdDev = sqrt(variancesample)
Throw an exception if the array is of length 0, or if the sample standard deviation is taken on an array of length less than 2.
array - An array of doubles.sample - True if the sample standard deviation is desired.
public static final double sumOfElements(double[] array)
public static double variance(double[] array)
public static double variance(double[] array,
boolean sample)
variance = (sum(X2) - (sum(X) / N)2) / N
The sample variance is computed as follows :
variancesample =
(sum(X2) - (sum(X) / N)2) / (N - 1)
Throw an exception if the array is of length 0, or if the sample variance is taken on an array of length less than 2.
protected static final int _nonZeroLength(double[] array,
java.lang.String methodName)
array - An array of doubles.methodName - A String representing the method name of the caller,
without parentheses.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||