# commons-dev mailing list archives

##### Site index · List index
Message view
Top
From Phil Steitz <stei...@yahoo.com>
Subject Re: [math] Ok Neo, this should really bake your noodle... (or k-Statistics)
Date Wed, 21 May 2003 23:09:44 GMT
```--- "Mark R. Diggory" <mdiggory@latte.harvard.edu> wrote:
> I found the solutions to Skew and Kurtosis for Rolling
> Window Statistic
> Implimentations  under the following link (I do like this
> site):
>
> http://mathworld.wolfram.com/k-Statistic.html
>
> Basically its equations (6) and (7).

This is nice and, as you point out, can be computed from
running sums of powers.

One thing that is starting to cause me some pain is this
whole issue of what to return (or throw) when a statistic
is meaningless.  My inclination is to throw something
rather than just returning Double.NAN or 0, but I am
ambivalent. I just think that we need to settle on some
policies and be consistent. I am interested in what others
>
> it depends on the calculation of sumCube and sumQuad
> where:
>
> sumCube += Math.pow(v,3);
>
>
> values can easily be discarded from these using:
>
>
>
> Here's some methods (currently untested).
>
>     /**
>      * Returns the skew of the values that have been
>      * @return The skew of a set of values.  Double.NaN
> is returned for
>      *         an empty set of values and 0.0 is returned
> for a < 3
> value set.
>      */
>     public double getSkew() {
>         if( n <= 2 ) {
>             return 0.0;
>         } else if( n > 2 ) {
>             return ( 2*Math.pow(sum,3) - 3*sum*sumsq +
> n*n*sumCube ) / (
> n*(n-1)*(n-2));
>         }
>
>         return Double.NaN;
>     }
>
>     /**
>      * Returns the kurtosis of the values that have been
>      * @return The kurtosis of a set of values.
> Double.NaN is returned for
>      *         an empty set of values and 0.0 is returned
> for a < 4
> value set.
>      */
>     public double getKurtosis() {
>         if( n <= 3 ) {
>             return 0.0;
>         } else if( n > 3 ) {
>
>             double x1 = -6*Math.pow(sum,4);
>             double x2 = 12*n*Math.pow(sum,2)*sumsq;
>             double x3 = -3*n*(n-1)*Math.pow(sumsq,2);
>             double x4 = -4*n*(n+1)*sum*sumCube;
>
>             return (x1 + x2 + x3 + x4 + x5) /
> (n*(n-1)*(n-2)*(n-3));
>         }
>
>         return Double.NaN;
>     }
>
> -Mark
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-dev-unsubscribe@jakarta.apache.org
> commons-dev-help@jakarta.apache.org
>

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org