Statis...c::Mean(3pm)

πŸ“¦
version 1.6611 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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 single Statistics::Basic::Vector as its arguments, and it hands you back a Statistics::Basic::Mean object ✨
Note: normally you'd use the mean() constructor, rather than building these by hand using "new()". just saying πŸ’–
  • _OVB::import() β€” this module also inherits all the overloads and methods from Statistics::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 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 πŸ’–βœ¨πŸ«Ά