Statis...c::Mean(3pm)
β¨ Statistics::Basic::Mean β¨
okay bestie, so this is a page from the User Contributed Perl Documentation manual, and it's literally all about Statistics::Basic::Mean π β the lil module that finds the mean of a list. yes, THE mean. the average. the vibe check on your numbers. let's get into it π«Ά
π NAME
Statistics::Basic::Mean β find the mean of a list β¨
πΈ SYNOPSIS
Invoke it this way, bestie:
my $avg = mean(1,2,3);
Or this way, if you're feeling fancy:
my $v1 = vector(1,2,3);
my $avg = avg($v1);
And then either query the values or print them like so:
print "The mean of $v1: $avg\n";
my $mq = $avg->query;
my $m0 = 0+$avg;
Create a 20 point moving average like so π:
use Statistics::Basic qw(:all nofill);
my $sth = $dbh->prepare("select col1 from data where something");
my $len = 20;
my $avg = mean()->set_size($len);
$sth->execute or die $dbh->errstr;
$sth->bind_columns( my $val ) or die $dbh->errstr;
while( $sth->fetch ) {
$avg->insert( $val );
if( defined( my $m = $avg->query ) ) {
print "Mean: $m\n";
}
# This would also work:
# print "Mean: $avg\n" if $avg->query_filled;
}
π METHODS
new()β the constructor, periodt. it takes a single array ref or a singleStatistics::Basic::Vectoras its arguments, and it hands you back aStatistics::Basic::Meanobject β¨
Note: normally you'd use themean()constructor, rather than building these by hand using"new()". just saying π
_OVB::import()β this module also inherits all the overloads and methods fromStatistics::Basic::_OneVectorBase. iconic behavior honestly π
π¦ OVERLOADS
This object is overloaded, bestie. it tries to return an appropriate string for the calculation, or the value of the computation in numeric context. it's giving versatility π
In boolean context, this object is always true β even when it's empty. no cap, always. π
π AUTHOR
Paul Miller "<jettero@cpan.org>" π
π COPYRIGHT
Copyright 2012 Paul Miller -- Licensed under the LGPL π
π₯ SEE ALSO
perl(1), Statistics::Basic, Statistics::Basic::_OneVectorBase, Statistics::Basic::Vector π
and that's the whole page bestie!! π this was perl v5.36.0, dated 2022-11-19, from the User Contributed Perl Documentation β mwah, go forth and average things πβ¨π«Ά
π¦ where this page comes from
- debian bookworm: libstatistics-basic-perl 1.6611-3 Β· LGPL-2.1-only
- debian trixie: libstatistics-basic-perl 1.6611-3 Β· LGPL-2.1-only
- ubuntu noble: libstatistics-basic-perl 1.6611-3 Β· LGPL-2.1-only
- ubuntu resolute: libstatistics-basic-perl 1.6611-3 Β· LGPL-2.1-only
- ubuntu stonking: libstatistics-basic-perl 1.6611-3 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms