Current File : //usr/local/share/man/man3/Statistics::Descriptive.3
.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
.    if \nF \{
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Statistics::Descriptive 3"
.TH Statistics::Descriptive 3 "2015-06-13" "perl v5.20.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Statistics::Descriptive \- Module of basic descriptive statistical functions.
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 6
\&  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);
\&  $Statistics::Descriptive::Tolerance = 1e\-10;
.Ve
.SH "DESCRIPTION"
.IX Header "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.
.PP
Whenever a division by zero may occur, the denominator is checked to be
greater than the value \f(CW$Statistics::Descriptive::Tolerance\fR, which
defaults to 0.0. You may want to change this value to some small
positive value such as 1e\-24 in order to obtain error messages in case
of very small denominators.
.PP
Many of the methods (both Sparse and Full) cache values so that subsequent
calls with the same arguments are faster.
.SH "METHODS"
.IX Header "METHODS"
.SS "Sparse Methods"
.IX Subsection "Sparse Methods"
.ie n .IP "$stat = Statistics::Descriptive::Sparse\->\fInew()\fR;" 5
.el .IP "\f(CW$stat\fR = Statistics::Descriptive::Sparse\->\fInew()\fR;" 5
.IX Item "$stat = Statistics::Descriptive::Sparse->new();"
Create a new sparse statistics object.
.ie n .IP "$stat\->\fIclear()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIclear()\fR;" 5
.IX Item "$stat->clear();"
Effectively the same as
.Sp
.Vb 3
\&  my $class = ref($stat);
\&  undef $stat;
\&  $stat = new $class;
.Ve
.Sp
except more efficient.
.ie n .IP "$stat\->add_data(1,2,3);" 5
.el .IP "\f(CW$stat\fR\->add_data(1,2,3);" 5
.IX Item "$stat->add_data(1,2,3);"
Adds data to the statistics variable. The cached statistical values are
updated automatically.
.ie n .IP "$stat\->\fIcount()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIcount()\fR;" 5
.IX Item "$stat->count();"
Returns the number of data items.
.ie n .IP "$stat\->\fImean()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fImean()\fR;" 5
.IX Item "$stat->mean();"
Returns the mean of the data.
.ie n .IP "$stat\->\fIsum()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIsum()\fR;" 5
.IX Item "$stat->sum();"
Returns the sum of the data.
.ie n .IP "$stat\->\fIvariance()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIvariance()\fR;" 5
.IX Item "$stat->variance();"
Returns the variance of the data.  Division by n\-1 is used.
.ie n .IP "$stat\->\fIstandard_deviation()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIstandard_deviation()\fR;" 5
.IX Item "$stat->standard_deviation();"
Returns the standard deviation of the data. Division by n\-1 is used.
.ie n .IP "$stat\->\fImin()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fImin()\fR;" 5
.IX Item "$stat->min();"
Returns the minimum value of the data set.
.ie n .IP "$stat\->\fImindex()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fImindex()\fR;" 5
.IX Item "$stat->mindex();"
Returns the index of the minimum value of the data set.
.ie n .IP "$stat\->\fImax()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fImax()\fR;" 5
.IX Item "$stat->max();"
Returns the maximum value of the data set.
.ie n .IP "$stat\->\fImaxdex()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fImaxdex()\fR;" 5
.IX Item "$stat->maxdex();"
Returns the index of the maximum value of the data set.
.ie n .IP "$stat\->\fIsample_range()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIsample_range()\fR;" 5
.IX Item "$stat->sample_range();"
Returns the sample range (max \- min) of the data set.
.SS "Full Methods"
.IX Subsection "Full Methods"
Similar to the Sparse Methods above, any Full Method that is called caches
the current result so that it doesn't have to be recalculated.  In some
cases, several values can be cached at the same time.
.ie n .IP "$stat = Statistics::Descriptive::Full\->\fInew()\fR;" 5
.el .IP "\f(CW$stat\fR = Statistics::Descriptive::Full\->\fInew()\fR;" 5
.IX Item "$stat = Statistics::Descriptive::Full->new();"
Create a new statistics object that inherits from
Statistics::Descriptive::Sparse so that it contains all the methods
described above.
.ie n .IP "$stat\->add_data(1,2,4,5);" 5
.el .IP "\f(CW$stat\fR\->add_data(1,2,4,5);" 5
.IX Item "$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.
.Sp
\&\fINote:  Calling add_data with an empty array will delete all of your
Full method cached values!  Cached values for the sparse methods are
not changed\fR
.ie n .IP "$stat\->add_data_with_samples([{1 => 10}, {2 => 20}, {3 => 30},]);" 5
.el .IP "\f(CW$stat\fR\->add_data_with_samples([{1 => 10}, {2 => 20}, {3 => 30},]);" 5
.IX Item "$stat->add_data_with_samples([{1 => 10}, {2 => 20}, {3 => 30},]);"
Add data to the statistics variable and set the number of samples each value has been
built with. The data is the key of each element of the input array ref, while
the value is the number of samples: [{data1 => smaples1}, {data2 => samples2}, ...]
.ie n .IP "$stat\->\fIget_data()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIget_data()\fR;" 5
.IX Item "$stat->get_data();"
Returns a copy of the data array.
.ie n .IP "$stat\->\fIget_data_without_outliers()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIget_data_without_outliers()\fR;" 5
.IX Item "$stat->get_data_without_outliers();"
Returns a copy of the data array without outliers. The number minimum of
samples to apply the outlier filtering is \f(CW$Statistics::Descriptive::Min_samples_number\fR,
4 by default.
.Sp
A function to detect outliers need to be defined (see \f(CW\*(C`set_outlier_filter\*(C'\fR),
otherwise the function will return an undef value.
.Sp
The filtering will act only on the most extreme value of the data set
(i.e.: value with the highest absolute standard deviation from the mean).
.Sp
If there is the need to remove more than one outlier, the filtering
need to be re-run for the next most extreme value with the initial outlier removed.
.Sp
This is not always needed since the test (for example Grubb's test) usually can only detect
the most exreme value. If there is more than one extreme case in a set,
then the standard deviation will be high enough to make neither case an outlier.
.ie n .IP "$stat\->set_outlier_filter($code_ref);" 5
.el .IP "\f(CW$stat\fR\->set_outlier_filter($code_ref);" 5
.IX Item "$stat->set_outlier_filter($code_ref);"
Set the function to filter out the outlier.
.Sp
\&\f(CW$code_ref\fR is the reference to the subroutine implemeting the filtering function.
.Sp
Returns \f(CW\*(C`undef\*(C'\fR for invalid values of \f(CW$code_ref\fR (i.e.: not defined or not a
code reference), \f(CW1\fR otherwise.
.RS 5
.IP "\(bu" 4
Example #1: Undefined code reference
.Sp
.Vb 2
\&    my $stat = Statistics::Descriptive::Full\->new();
\&    $stat\->add_data(1, 2, 3, 4, 5);
\&
\&    print $stat\->set_outlier_filter(); # => undef
.Ve
.IP "\(bu" 4
Example #2: Valid code reference
.Sp
.Vb 1
\&    sub outlier_filter { return $_[1] > 1; }
\&
\&    my $stat = Statistics::Descriptive::Full\->new();
\&    $stat\->add_data( 1, 1, 1, 100, 1, );
\&
\&    print $stat\->set_outlier_filter( \e&outlier_filter ); # => 1
\&    my @filtered_data = $stat\->get_data_without_outliers();
\&    # @filtered_data is (1, 1, 1, 1)
.Ve
.Sp
In this example the series is really simple and the outlier filter function as well.
For more complex series the outlier filter function might be more complex
(see Grubbs' test for outliers).
.Sp
The outlier filter function will receive as first parameter the Statistics::Descriptive::Full object,
as second the value of the candidate outlier. Having the object in the function
might be useful for complex filters where statistics property are needed (again see Grubbs' test for outlier).
.RE
.RS 5
.RE
.ie n .IP "$stat\->set_smoother({ method => 'exponential', coeff => 0, });" 5
.el .IP "\f(CW$stat\fR\->set_smoother({ method => 'exponential', coeff => 0, });" 5
.IX Item "$stat->set_smoother({ method => 'exponential', coeff => 0, });"
Set the method used to smooth the data and the smoothing coefficient.
See \f(CW\*(C`Statistics::Smoother\*(C'\fR for more details.
.ie n .IP "$stat\->\fIget_smoothed_data()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIget_smoothed_data()\fR;" 5
.IX Item "$stat->get_smoothed_data();"
Returns a copy of the smoothed data array.
.Sp
The smoothing method and coefficient need to be defined (see \f(CW\*(C`set_smoother\*(C'\fR),
otherwise the function will return an undef value.
.ie n .IP "$stat\->\fIsort_data()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIsort_data()\fR;" 5
.IX Item "$stat->sort_data();"
Sort the stored data and update the mindex and maxdex methods.  This
method uses perl's internal sort.
.ie n .IP "$stat\->\fIpresorted\fR\|(1);" 5
.el .IP "\f(CW$stat\fR\->\fIpresorted\fR\|(1);" 5
.IX Item "$stat->presorted;"
.PD 0
.ie n .IP "$stat\->\fIpresorted()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIpresorted()\fR;" 5
.IX Item "$stat->presorted();"
.PD
If called with a non-zero 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.
.ie n .IP "$stat\->\fIskewness()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIskewness()\fR;" 5
.IX Item "$stat->skewness();"
Returns the skewness of the data.
A value of zero is no skew, negative is a left skewed tail,
positive is a right skewed tail.
This is consistent with Excel.
.ie n .IP "$stat\->\fIkurtosis()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIkurtosis()\fR;" 5
.IX Item "$stat->kurtosis();"
Returns the kurtosis of the data.
Positive is peaked, negative is flattened.
.ie n .IP "$x = $stat\->percentile(25);" 5
.el .IP "\f(CW$x\fR = \f(CW$stat\fR\->percentile(25);" 5
.IX Item "$x = $stat->percentile(25);"
.PD 0
.ie n .IP "($x, $index) = $stat\->percentile(25);" 5
.el .IP "($x, \f(CW$index\fR) = \f(CW$stat\fR\->percentile(25);" 5
.IX Item "($x, $index) = $stat->percentile(25);"
.PD
Sorts the data and returns the value that corresponds to the
percentile as defined in \s-1RFC2330:\s0
.RS 5
.IP "\(bu" 4
For example, given the 6 measurements:
.Sp
\&\-2, 7, 7, 4, 18, \-5
.Sp
Then F(\-8) = 0, F(\-5) = 1/6, F(\-5.0001) = 0, F(\-4.999) = 1/6, F(7) =
5/6, F(18) = 1, F(239) = 1.
.Sp
Note that we can recover the different measured values and how many
times each occurred from F(x) \*(-- no information regarding the range
in values is lost.  Summarizing measurements using histograms, on the
other hand, in general loses information about the different values
observed, so the \s-1EDF\s0 is preferred.
.Sp
Using either the \s-1EDF\s0 or a histogram, however, we do lose information
regarding the order in which the values were observed.  Whether this
loss is potentially significant will depend on the metric being
measured.
.Sp
We will use the term \*(L"percentile\*(R" to refer to the smallest value of x
for which F(x) >= a given percentage.  So the 50th percentile of the
example above is 4, since F(4) = 3/6 = 50%; the 25th percentile is
\&\-2, since F(\-5) = 1/6 < 25%, and F(\-2) = 2/6 >= 25%; the 100th
percentile is 18; and the 0th percentile is \-infinity, as is the 15th
percentile, which for ease of handling and backward compatibility is returned
as \fIundef()\fR by the function.
.Sp
Care must be taken when using percentiles to summarize a sample,
because they can lend an unwarranted appearance of more precision
than is really available.  Any such summary must include the sample
size N, because any percentile difference finer than 1/N is below the
resolution of the sample.
.RE
.RS 5
.Sp
(Taken from:
\&\fI\s-1RFC2330 \-\s0 Framework for \s-1IP\s0 Performance Metrics\fR,
Section 11.3.  Defining Statistical Distributions.
\&\s-1RFC2330\s0 is available from:
<http://www.ietf.org/rfc/rfc2330.txt> .)
.Sp
If the percentile method is called in a list context then it will
also return the index of the percentile.
.RE
.ie n .IP "$x = $stat\->quantile($Type);" 5
.el .IP "\f(CW$x\fR = \f(CW$stat\fR\->quantile($Type);" 5
.IX Item "$x = $stat->quantile($Type);"
Sorts the data and returns estimates of underlying distribution quantiles based on one
or two order statistics from the supplied elements.
.Sp
This method use the same algorithm as Excel and R language (quantile \fBtype 7\fR).
.Sp
The generic function quantile produces sample quantiles corresponding to the given probabilities.
.Sp
\&\fB\f(CB$Type\fB\fR is an integer value between 0 to 4 :
.Sp
.Vb 5
\&  0 => zero quartile (Q0) : minimal value
\&  1 => first quartile (Q1) : lower quartile = lowest cut off (25%) of data = 25th percentile
\&  2 => second quartile (Q2) : median = it cuts data set in half = 50th percentile
\&  3 => third quartile (Q3) : upper quartile = highest cut off (25%) of data, or lowest 75% = 75th percentile
\&  4 => fourth quartile (Q4) : maximal value
.Ve
.Sp
Exemple :
.Sp
.Vb 8
\&  my @data = (1..10);
\&  my $stat = Statistics::Descriptive::Full\->new();
\&  $stat\->add_data(@data);
\&  print $stat\->quantile(0); # => 1
\&  print $stat\->quantile(1); # => 3.25
\&  print $stat\->quantile(2); # => 5.5
\&  print $stat\->quantile(3); # => 7.75
\&  print $stat\->quantile(4); # => 10
.Ve
.ie n .IP "$stat\->\fImedian()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fImedian()\fR;" 5
.IX Item "$stat->median();"
Sorts the data and returns the median value of the data.
.ie n .IP "$stat\->\fIharmonic_mean()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIharmonic_mean()\fR;" 5
.IX Item "$stat->harmonic_mean();"
Returns the harmonic mean of the data.  Since the mean is undefined
if any of the data are zero or if the sum of the reciprocals is zero,
it will return undef for both of those cases.
.ie n .IP "$stat\->\fIgeometric_mean()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIgeometric_mean()\fR;" 5
.IX Item "$stat->geometric_mean();"
Returns the geometric mean of the data.
.ie n .IP "my $mode = $stat\->\fImode()\fR;" 5
.el .IP "my \f(CW$mode\fR = \f(CW$stat\fR\->\fImode()\fR;" 5
.IX Item "my $mode = $stat->mode();"
Returns the mode of the data. The mode is the most commonly occuring datum.
See <http://en.wikipedia.org/wiki/Mode_%28statistics%29> . If all values
occur only once, then \fImode()\fR will return undef.
.ie n .IP "$stat\->trimmed_mean(ltrim[,utrim]);" 5
.el .IP "\f(CW$stat\fR\->trimmed_mean(ltrim[,utrim]);" 5
.IX Item "$stat->trimmed_mean(ltrim[,utrim]);"
\&\f(CW\*(C`trimmed_mean(ltrim)\*(C'\fR returns the mean with a fraction \f(CW\*(C`ltrim\*(C'\fR
of entries at each end dropped. \f(CW\*(C`trimmed_mean(ltrim,utrim)\*(C'\fR
returns the mean after a fraction \f(CW\*(C`ltrim\*(C'\fR has been removed from the
lower end of the data and a fraction \f(CW\*(C`utrim\*(C'\fR has been removed from the
upper end of the data.  This method sorts the data before beginning
to analyze it.
.Sp
All calls to \fItrimmed_mean()\fR are cached so that they don't have to be
calculated a second time.
.ie n .IP "$stat\->frequency_distribution_ref($partitions);" 5
.el .IP "\f(CW$stat\fR\->frequency_distribution_ref($partitions);" 5
.IX Item "$stat->frequency_distribution_ref($partitions);"
.PD 0
.ie n .IP "$stat\->frequency_distribution_ref(\e@bins);" 5
.el .IP "\f(CW$stat\fR\->frequency_distribution_ref(\e@bins);" 5
.IX Item "$stat->frequency_distribution_ref(@bins);"
.ie n .IP "$stat\->\fIfrequency_distribution_ref()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIfrequency_distribution_ref()\fR;" 5
.IX Item "$stat->frequency_distribution_ref();"
.PD
\&\f(CW\*(C`frequency_distribution_ref($partitions)\*(C'\fR slices the data into
\&\f(CW$partition\fR sets (where \f(CW$partition\fR is greater than 1) and counts the
number of items that fall into each partition. It returns a reference to
a hash 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,
.Sp
.Vb 5
\&   $stat\->add_data(1,1.5,2,2.5,3,3.5,4);
\&   $f = $stat\->frequency_distribution_ref(2);
\&   for (sort {$a <=> $b} keys %$f) {
\&      print "key = $_, count = $f\->{$_}\en";
\&   }
.Ve
.Sp
prints
.Sp
.Vb 2
\&   key = 2.5, count = 4
\&   key = 4, count = 3
.Ve
.Sp
since there are four items less than or equal to 2.5, and 3 items
greater than 2.5 and less than 4.
.Sp
\&\f(CW\*(C`frequency_distribution_refs(\e@bins)\*(C'\fR provides the bins that are to be used
for the distribution.  This allows for non-uniform distributions as
well as trimmed or sample distributions to be found.  \f(CW@bins\fR must
be monotonic and contain at least one element.  Note that unless the
set of bins contains the range that the total counts returned will
be less than the sample size.
.Sp
Calling \f(CW\*(C`frequency_distribution_ref()\*(C'\fR with no arguments returns the last
distribution calculated, if such exists.
.ie n .IP "my %hash = $stat\->frequency_distribution($partitions);" 5
.el .IP "my \f(CW%hash\fR = \f(CW$stat\fR\->frequency_distribution($partitions);" 5
.IX Item "my %hash = $stat->frequency_distribution($partitions);"
.PD 0
.ie n .IP "my %hash = $stat\->frequency_distribution(\e@bins);" 5
.el .IP "my \f(CW%hash\fR = \f(CW$stat\fR\->frequency_distribution(\e@bins);" 5
.IX Item "my %hash = $stat->frequency_distribution(@bins);"
.ie n .IP "my %hash = $stat\->\fIfrequency_distribution()\fR;" 5
.el .IP "my \f(CW%hash\fR = \f(CW$stat\fR\->\fIfrequency_distribution()\fR;" 5
.IX Item "my %hash = $stat->frequency_distribution();"
.PD
Same as \f(CW\*(C`frequency_distribution_ref()\*(C'\fR except that returns the hash clobbered
into the return list. Kept for compatibility reasons with previous
versions of Statistics::Descriptive and using it is discouraged.
.ie n .IP "$stat\->\fIleast_squares_fit()\fR;" 5
.el .IP "\f(CW$stat\fR\->\fIleast_squares_fit()\fR;" 5
.IX Item "$stat->least_squares_fit();"
.PD 0
.ie n .IP "$stat\->least_squares_fit(@x);" 5
.el .IP "\f(CW$stat\fR\->least_squares_fit(@x);" 5
.IX Item "$stat->least_squares_fit(@x);"
.PD
\&\f(CW\*(C`least_squares_fit()\*(C'\fR performs a least squares fit on the data,
assuming a domain of \f(CW@x\fR or a default of 1..$stat\->\fIcount()\fR.  It
returns an array of four elements \f(CW\*(C`($q, $m, $r, $rms)\*(C'\fR where
.RS 5
.ie n .IP """$q and $m""" 4
.el .IP "\f(CW$q and $m\fR" 4
.IX Item "$q and $m"
satisfy the equation C($y = \f(CW$m\fR*$x + \f(CW$q\fR).
.ie n .IP "$r" 4
.el .IP "\f(CW$r\fR" 4
.IX Item "$r"
is the Pearson linear correlation cofficient.
.ie n .IP "$rms" 4
.el .IP "\f(CW$rms\fR" 4
.IX Item "$rms"
is the root-mean-square error.
.RE
.RS 5
.Sp
If case of error or division by zero, the empty list is returned.
.Sp
The array that is returned can be \*(L"coerced\*(R" into a hash structure
by doing the following:
.Sp
.Vb 2
\&  my %hash = ();
\&  @hash{\*(Aqq\*(Aq, \*(Aqm\*(Aq, \*(Aqr\*(Aq, \*(Aqerr\*(Aq} = $stat\->least_squares_fit();
.Ve
.Sp
Because calling \f(CW\*(C`least_squares_fit()\*(C'\fR with no arguments defaults
to using the current range, there is no caching of the results.
.RE
.SH "REPORTING ERRORS"
.IX Header "REPORTING ERRORS"
I read my email frequently, but since adopting this module I've added 2
children and 1 dog to my family, so please be patient about my response
times.  When reporting errors, please include the following to help
me out:
.IP "\(bu" 4
Your version of perl.  This can be obtained by typing perl \f(CW\*(C`\-v\*(C'\fR at
the command line.
.IP "\(bu" 4
Which version of Statistics::Descriptive you're using.  As you can
see below, I do make mistakes.  Unfortunately for me, right now
there are thousands of \s-1CD\s0's with the version of this module with
the bugs in it.  Fortunately for you, I'm a very patient module
maintainer.
.IP "\(bu" 4
Details about what the error is.  Try to narrow down the scope
of the problem and send me code that I can run to verify and
track it down.
.SH "AUTHOR"
.IX Header "AUTHOR"
Current maintainer:
.PP
Shlomi Fish, <http://www.shlomifish.org/> , \f(CW\*(C`shlomif@cpan.org\*(C'\fR
.PP
Previously:
.PP
Colin Kuskie
.PP
My email address can be found at http://www.perl.com under Who's Who
or at: http://search.cpan.org/author/COLINK/.
.SH "CONTRIBUTORS"
.IX Header "CONTRIBUTORS"
Fabio Ponciroli & Adzuna Ltd. team (outliers handling)
.SH "REFERENCES"
.IX Header "REFERENCES"
\&\s-1RFC2330,\s0 Framework for \s-1IP\s0 Performance Metrics
.PP
The Art of Computer Programming, Volume 2, Donald Knuth.
.PP
Handbook of Mathematica Functions, Milton Abramowitz and Irene Stegun.
.PP
Probability and Statistics for Engineering and the Sciences, Jay Devore.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright (c) 1997,1998 Colin Kuskie. All rights reserved.  This
program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
.PP
Copyright (c) 1998 Andrea Spinelli. All rights reserved.  This program
is free software; you can redistribute it and/or modify it under the
same terms as Perl itself.
.PP
Copyright (c) 1994,1995 Jason Kastner. All rights
reserved.  This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
.SH "LICENSE"
.IX Header "LICENSE"
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.