Statistics in perl

Perl is one of script languages I confidently use it daily. I love it, even addict to it. I use it for data manipulation, basic statistic. There are a number of perl modules dedicated to number crash:

Number::Format
Statistics::Basic
Statistics::Descriptive
Statistics::TTest
Statistics::Distribution

rand() and Math::Rand
cpan2rpm is nice tool to install perl model as rpm in fedora (my linux)

My favourate module is  Statistics::Basic.  In script, call it by

use Statistics::Basic qw(:all);

here are a few simple uses

my $v1  = vector(4,6,9);
my $v2  = vector(1,2,3);
my $mean = mean($v2);
my $var = variance ($v2);
my $std = stddev($v1);
my $cov = covariance(  $v1, $v2 );
my $cor = correlation( $v1, $v2 );

to install a perl module at your home directory

  • % perl Makefile.PL PREFIX=/usr/home/USERNAME/perl_mod
  • % make
  • % make test
  • % make install
  • % make clean

in fact, you can simply copy Basic dir and Basic.pm to ~/perl_mod/

to use your local module,  cal this first

use lib "$ENV{'HOME'}/perl_mod";

This paper gave a comprehensive review on perl application in statitics (Using Perl for Statistics: Data Processing and Statistical Computing).
    About these ads

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s