Statis...ariance(3pm)
π Statistics::Basic::Variance β a.k.a. the Statis...ariance(3pm) page from User Contributed Perl Documentation, section 3pm π
β¨ NAME β¨
Statistics::Basic::Variance β bestie, this is the module that finds the variance of a list. That's it. That's the whole job. π¦
πΈ SYNOPSIS πΈ
Okay so you can summon it like this:
my $variance = variance(1,2,3);
Or, if you're feeling extra, like this:
my $v1 = vector(1,2,3);
my $var = var($v1);
And then you can either ask it for the numbers or just print them, like so:
print "The variance of $v1: $variance\n";
my $vq = $var->query;
my $v0 = 0+$var;
Wanna build a 20 point "moving" variance? Iconic. Do it like this:
use Statistics::Basic qw(:all nofill);
my $sth = $dbh->prepare("select col1 from data where something");
my $len = 20;
my $var = var()->set_size($len);
$sth->execute or die $dbh->errstr;
$sth->bind_columns( my $val ) or die $dbh->errstr;
while( $sth->fetch ) {
$var->insert( $val );
if( defined( my $v = $var->query ) ) {
print "Variance: $v\n";
}
# This would also work:
# print "Variance: $v\n" if $var->query_filled;
}
π METHODS π
new()β the constructor, she's the main character π. She takes a list of values, a single array ref, or a singleStatistics::Basic::Vectoras arguments. She hands you back aStatistics::Basic::Varianceobject. π
Note: normally you'd use themean()constructor rather than building these by hand using"new()". Just saying. π
query_mean()β returns theStatistics::Basic::Meanobject that got used in the variance computation. Very demure, very mindful. β¨_OVB::import()β this module also inherits all the overloads and methods fromStatistics::Basic::_OneVectorBase. Slay. π
π«Ά AUTHOR π«Ά
Paul Miller "<jettero@cpan.org>"
And he says, and I quote: "I am using this software in my own projects... If you find bugs, please please please let me know. :) Actually, let me know if you find it handy at all. Half the fun of releasing this stuff is knowing that people use it."
Not him being the sweetest π honestly we love a dev who actually wants to hear from us. Go tell him if you find a bug, and also go tell him if you just think it's neat. π
π₯ OVERLOADS π₯
This object is overloaded, meaning she reads the room and adapts. π She tries to return an appropriate string for the calculation, or the value of the computation when you're in numeric context.
And in boolean context? This object is always true β even when it's empty. No cap. π§
π COPYRIGHT π
Copyright 2012 Paul Miller -- Licensed under the LGPL
β SEE ALSO β
perl(1)Statistics::BasicStatistics::Basic::_OneVectorBaseStatistics::Basic::Vector
Mwah, that's the whole page, bestie. Sending you off with the receipt: this was perl v5.36.0, dated 2022-11-19, and it's the Statis...ariance(3pm) page β periodt. πβ¨ππ¦
π¦ 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