The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


 Statistics::TTest - Perl module to perform T-test on 2 independent samples
 Statistics::TTest::Sufficient - Perl module to perfrom T-Test on 2 indepdent samples using sufficient statistics


 #example for Statistics::TTest
 use Statistics::PointEstimation;
 use Statistics::TTest;
 my @r1=();
 my @r2=();
 my $rand;
  for($i=1;$i<=32;$i++) #generate a uniformly distributed sample with mean=5   

          push @r1,$rand;
          push @r2,$rand;

 my $ttest = new Statistics::TTest;  
 $ttest->print_t_test();  #list out t-test related data
 #the following thes same as calling output_t_test() (you can check if $ttest->{valid}==1 to check if the data is valid.)
 my $s1=$ttest->{s1};  #sample 1  a Statistics::PointEstimation object
 my $s2=$ttest->{s2};  #sample 2  a Statistics::PointEstimation object
 print "*****************************************************\n\n";
 print "*****************************************************\n\n";
 print "*****************************************************\n\n";
 print "Comparison of these 2 independent samples.\n";
 print "\t F-statistic=",$ttest->f_statistic()," , cutoff F-statistic=",$ttest->f_cutoff(),
        " with alpha level=",$ttest->alpha*2," and  df =(",$ttest->df1,",",$ttest->df2,")\n"; 
 { print "\tequal variance assumption is accepted(not rejected) since F-statistic < cutoff F-statistic\n";}
 { print "\tequal variance assumption is  rejected since F-statistic > cutoff F-statistic\n";}
 print "\tdegree of freedom=",$ttest->df," , t-statistic=T=",$ttest->t_statistic," Prob >|T|=",$ttest->{t_prob},"\n";
 print "\tthe null hypothesis (the 2 samples have the same mean) is ",$ttest->null_hypothesis(),
         " since the alpha level is ",$ttest->alpha()*2,"\n";
 print "\tdifference of the mean=",$ttest->mean_difference(),", standard error=",$ttest->standard_error(),"\n";
 print "\t the estimate of the difference of the mean is ", $ttest->mean_difference()," +/- ",$ttest->delta(),"\n\t",
        " or (",$ttest->lower_clm()," to ",$ttest->upper_clm," ) with ",$ttest->significance," % of confidence\n"; 
 #example for Statistics::TTest::Sufficient
 use Statistics::PointEstimation;
 use Statistics::TTest;
 my %sample1=(
        'count' =>30,
        'mean' =>3.98,
        'variance' =>2.63

 my %sample2=(

 my $ttest = new Statistics::TTest::Sufficient;  



 This is the Statistical T-Test module to compare 2 independent samples. It takes 2 array of point measures, 
 compute the confidence intervals using the PointEstimation module (which is also included in this package)
  and use the T-statistic to test the null hypothesis. If the null hypothesis is rejected, the difference 
  will be given as the lower_clm and upper_clm of the TTest object. 


 This module is a subclass of Statistics::TTest. Instead of taking the real data points as the input, 
 it will compute the confidence intervals based on the sufficient statistics and the sample size inputted. 
 To use this module, you need to pass the sample size, the sample mean , and the sample variance into the load_data()
 function. The output will be exactly the same as the Statistics::TTest Module.


Yun-Fang Juan , Yahoo! Inc. (


Statistics::Descriptive Statistics::Distributions Statistics::PointEstimation