|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpapaya.Descriptive.Weighted
public static class Descriptive.Weighted
Contains methods related to weighted datasets.
Method Summary | |
---|---|
static float |
mean(float[] data,
float[] weights)
Returns the weighted mean of a data sequence. |
static float |
rms(float sumOfProducts,
float sumOfSquaredProducts)
Returns the weighted RMS (Root-Mean-Square) of a data sequence. |
static float |
var(float[] data,
float[] weights,
boolean unbiased)
Returns the weighted variance of a data sequence of length N There are (unfortunately) many different definitions of the unbiased weighted variance. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static float mean(float[] data, float[] weights)
Sum (data[i] * weights[i]) / Sum ( weights[i] )
.
public static float rms(float sumOfProducts, float sumOfSquaredProducts)
Sum( data[i] * data[i] * weights[i]) / Sum( data[i] * weights[i] )
,
or in other words sumOfProducts / sumOfSquaredProducts
.
sumOfProducts
- == Sum( data[i] * weights[i] )
.sumOfSquaredProducts
- == Sum( data[i] * data[i] * weights[i] )
.public static float var(float[] data, float[] weights, boolean unbiased)
weighted.var(x,w,unbiased=true) = biasCorrection * Sum ( w[i] * (x[i] - mu_w)^2 ) / Sum(w[i]).where
mu_w
corresponds to the weighted mean and the biasCorrection
term
biasCorrection = ( Sum(w[i]) )^2 / ( ( Sum(w[i]) )^2 - Sum( w[i]^2 ) ).corrects for the bias in the variance. weighted.var(x,w,unbiased=false) computes the biased weighted variance and is given by the formula above, but without the correction factor.
The formula above agrees with that presented in
the NIST Information Technology Laboratory page.
The algorithm used, is a one-pass formula credited to
"D. H. D. West (1979). Communications of the ACM, 22, 9, 532-535:
Updating Mean and Variance Estimates: An Improved Method", and spelled out under the
weighted incremental algorithm section of the link.
unbiased
- set to true to return the unbiased variance (division by (N-1)), false to return the biased value (division by N).
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |