Skip to content

Instantly share code, notes, and snippets.

@waffle2k
Created May 18, 2011 17:25
Show Gist options
  • Save waffle2k/979060 to your computer and use it in GitHub Desktop.
Save waffle2k/979060 to your computer and use it in GitHub Desktop.
Run some simple stats on a bunch of integers
[prod.b]pblair@b009:/mail/log/log01/smtprelay/20110518$ cat ~/stats.pl
#!/usr/bin/perl
use strict;
use warnings;
use lib("/home/pblair/lib");
use Statistics::Descriptive;
my $stat = Statistics::Descriptive::Full->new();
while(<>){
$stat->add_data( $_ );
}
my $mean = $stat->mean();
my $var = $stat->variance();
my $tm = $stat->trimmed_mean(.25);
my $std = $stat->standard_deviation();
$Statistics::Descriptive::Tolerance = 1e-10;
printf "Mean: %10.4f Var: %10.4f Std Dev: %10.4f Trimmed mean: %10.4f\n",
$mean,
$var,
$std,
$tm ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment