NAME
Statistics::Descriptive  Module of basic descriptive statistical functions.
SYNOPSIS
use Statistics::Descriptive;
$stat = Statistics::Descriptive::Full>new();
$stat>add_data(1,2,3,4);
$mean = $stat>mean();
$var = $stat>variance();
$tm = $stat>trimmed_mean(.25);
DESCRIPTION
This module provides basic functions used in descriptive statistics. It has an object oriented design and supports two different types of data storage and calculation objects: 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.
METHODS
Sparse Methods
 $stat = Statistics::Descriptive::Sparse>new();

Create a new sparse statistics object.
 $stat>add_data(1,2,3);

Adds data to the statistics variable. The cached statistical values are updated automatically.
 $stat>count();

Returns the number of data items.
 $stat>mean();

Returns the mean of the data.
 $stat>sum();

Returns the sum of the data.
 $stat>variance();

Returns the variance of the data. Division by n1 is used.
 $stat>standard_deviation();

Returns the standard deviation of the data. Division by n1 is used.
 $stat>min();

Returns the minimum value of the data set.
 $stat>mindex();

Returns the index of the minimum value of the data set.
 $stat>max();

Returns the maximum value of the data set.
 $stat>maxdex();

Returns the index of the maximum value of the data set.
 $stat>sample_range();

Returns the sample range (max  min) of the data set.
Full Methods
 $stat = Statistics::Descriptive::Full>new();

Create a new statistics object that with Statistics::Descriptive::Sparse as its base method so that it inherits all the methods described above.
 $stat>add_data(1,2,4,5);

Adds data to the statistics variable. All of the sparse statistical values are updated and cached. Cached values from full methods are deleted since they are no longer valid. Note: Calling add_data with an empty array will delete all of your cached values!
 $stat>get_data();

Returns a copy of the data array.
 $stat>sort_data();

Sort the stored data and update the mindex and maxdex methods.
 $stat>presorted(1);

If called with a nonzero argument, this method sets a flag that says the data is already sorted and need not be sorted again. Since some of the methods in this class require sorted data, this saves some time. If you supply sorted data to the object, call this method to prevent the data from being sorted again. The flag is cleared whenever add_data is called. Calling the method without an argument returns the value of the flag.
 $stat>median();

Returns the median value of the data.
 $stat>harmonic_mean();

Returns the harmonic mean of the data.
 $stat>geometric_mean();

Returns the geometric mean of the data.
 $stat>mode();

Returns the mode of the data.
 $stat>trimmed_mean(ltrim[,utrim]);

trimmed_mean(ltrim)
returns the mean with a fractionltrim
of entries at each end dropped.trimmed_mean(ltrim,utrim)
returns the mean after a fractionltrim
has been removed from the lower end of the data and a fractionutrim
has been removed from the upper end of the data.  $stat>frequency_distribution();

frequency_distribution(partitions)
slices the data intopartition
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>add_data(1,1.5,2,2.5,3,3.5,4); %f = $stat>frequency_distribution(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.
 $stat>least_squares_fit([@x]);

least_squares_fit()
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.least_squares_fit(@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) 1997 Colin Kuskie <colink@latticesemi.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
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
 v2.0

August 1997  Fixed errors in removing cached values (they weren't being removed!) and added sort_data and presorted methods.
June 1997  Rewrote OO interface, modified function distribution, added mindex, maxdex.
 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 email correspondence with Anno Siegel.
 v.10

December 1994  Initital concept, released to perl5porters list.
1 POD Error
The following errors were encountered while parsing the POD:
 Around line 526:
'=item' outside of any '=over'
=over without closing =back