Jason Kastner > StatisticsDescriptive > Statistics::Descriptive

Download:
StatisticsDescriptive-1.1.tar.gz

Dependencies

Annotate this POD

# NAME

Statistics::Descriptive - Module of basic descriptive statistical functions.

# SYNOPSIS

use Statistics::Descriptive;
\$stat = new Statistics::Descriptive;
\$stat->AddData(1,2,3,4);
\$mean = \$stat->Mean();
\$var  = \$stat->Variance();
\$tm  =  \$stat->TrimmedMean(.25);

# DESCRIPTION

This module provides basic functions used in descriptive statistics. It has an object oriented design and supports two different modes of data storage and calculations; sparse and full. With the sparse method, none of the data is stored and only a few statistical measures are available. Using the full method, the entire data set is retained and additional functions are available.

# SPARSE FUNCTIONS

sparse

Create a new sparse statistics variable.

AddData

Adds data to the statistics variable. The cached statistical values are updated automatically.

Count

Returns the number of data items.

Mean

Returns the mean of the data.

Sum

Returns the sum of the data.

Variance

Returns the variance of the data. Division by n-1 is used.

StandardDeviation

Returns the standard deviation of the data. Division by n-1 is used.

# FULL FUNCTIONS

new

Create a new statistics element. All the data is retained and all defined functions are available.

full

Synonymous with new.

AddData

Adds data to the statistics variable. The only variables which are automatically updated and re-cached are Count, Mean, Sum, Variance, and StandardDeviation. All other previously cached results are deleted since with the addition of new data they are no longer valid.

Other Functions

In addition to the functions mentioned in the sparse section, the following functions are also available when using full variables.

GetData

Returns a copy of the data.

Max

Returns the maximum value in the data set.

Min

Returns the minimum value in the data set.

SampleRange

Returns the sample range of the data.

Median

Returns the median value of the data.

HarmonicMean

Returns the harmonic mean of the data.

GeometricMean

Returns the geometric mean of the data.

Mode

Returns the mode of the data.

TrimmedMean

TrimmedMean(trim) returns the mean with a fraction trim of entries at each end dropped. TrimmedMean(ltrim,utrim) returns the mean after a fraction ltrim has been removed from the lower end of the data and a fraction utrim has been removed from the upper end of the data.

FrequencyDistribution

FrequencyDistribution(partitions) slices the data into partition sets and counts the number of items that fall into each partition. It returns an associative array where the keys are the numerical values of the partitions used. The minimum value of the data set is not a key and the maximum value of the data set is always a key. The number of entries for a particular partition key are the number of items which are greater than the previous partition key and less then or equal to the current partition key. As an example,

\$stat->AddData(1,1.5,2,2.5,3,3.5,4);
%f = \$stat->FrequencyDistribution(2);
for (sort {\$a <=> \$b} keys %f) {
print "key = \$_, count = \$f{\$_}\n";
}

prints

key = 2.5, count = 4
key = 4, count = 3

since there are four items less than or equal to 2.5, and 3 items greater than 2.5 and less than 4.

LeastSquaresFit

LeastSquaresFit() performs a least squares fit on the data, assuming a domain of 1,2,3... It returns an array of two elements; the value in the zeroth position is the constant (x^0) term and the value in the first position is the coeffiecient of the x^1 term. LeastSquaresFit(@x) uses the values in @x as the domain.

# REFERENCES

The Art of Computer Programming, Volume 2, Donald Knuth.

Handbook of Mathematica Functions, Milton Abramowitz and Irene Stegun.

Probability and Statistics for Engineering and the Sciences, Jay Devore.

# COPYRIGHT

Copyright (c) 1994,1995 Jason Kastner <jason@wagner.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

# REVISION HISTORY

v1.1

April 1995 - Added LeastSquaresFit and FrequencyDistribution.

v1.0

March 1995 - Released to comp.lang.perl and placed on archive sites.

v.20

December 1994 - Complete rewrite after extensive and invaluable e-mail correspondence with Anno Siegel.

v.10

December 1994 - Initital concept, released to perl5-porters list.

syntax highlighting: