On Thu Jan 04 05:01:58 2007, vassilii@tarunz.org wrote:
Show quoted text> Just to bump it up, let me post a lazy man's version of the computation
> that I had implemented. It suffers from 2 drawbacks 1) i don't ever
> cache the results 2) I didn't try to do it online (and hence put it into
> Sparse), because I was lazy at estimating the accumulated numerical
errors.
Show quoted text>
> Therefore I am showing it implemented as a subclass of Full, but one can
> easily just shove the same methods I provide into Full directly (at
> least, add the caching if you do so). Adding something to Simple in a
> rewritten online form would be the best, of course. Even better would
> be to generalize the accumulation of centered higher moments, providing
> up to which moments one is interested on the construction, maybe, and
> rewriting the skew/kurtosis in these generic methods' terms.
>
> Vassilii
>
> {
> package Statistics::Descriptive::FullWithSkewAndKurtosis;
> @ISA = qw(Statistics::Descriptive::Full);
> sub skew {
> my $self = shift;
> my $mean = $self->{mean};
> my $sd = $self->{standard_deviation};
> my $count = $self->{count};
> my $skew = 0;
> for (@{ $self->{data} }) {
> $skew += ( ($_ - $mean)/$sd ) ** 3 / $count;
> }
> return $skew;
> }
>
> sub kurtosis {
> my $self = shift;
> my $mean = $self->{mean};
> my $sd = $self->{standard_deviation};
> my $count = $self->{count};
> my $kurt = 0;
> for (@{ $self->{data} }) {
> $kurt += ( ($_ - $mean)/$sd ) ** 4 / $count;
> }
> return $kurt - 3;
> }
> }
>
Well, we need something better that will work on ::Sparse too, and use
the higher moments in the calculation, and not be so execessive on using
"/" again and again.
Can you supply a patch (along with suitable unit tests) that implements
this? Use the repository here:
http://svn.berlios.de/svnroot/repos/web-cpan/Statistics-Descriptive/
Otherwise, I fear I may have to close this bug due to lack of interest
Regards,
Shlomi Fish