Location : Home > Languages > Perl > Package Title : Statistics::TTest |
![]() |
Statistics::TTest - 独立 2 標本に対する t-検定
Statistics::TTest::Sufficient - 独立 2 標本に対する十分統計量を用いた t-検定
# Statistics::TTest の例 use Statistics::PointEstimation; use Statistics::TTest; my @r1=(); my @r2=(); my $rand; for($i=1;$i<=32;$i++) # 平均が 5 の一様分布に従う標本の生成 { $rand=rand(10); push @r1,$rand; $rand=rand(10)-2; push @r2,$rand; } my $ttest = new Statistics::TTest; $ttest->set_significance(90); $ttest->load_data(\@r1,\@r2); $ttest->output_t_test(); $ttest->set_significance(99); $ttest->print_t_test(); # t-検定関連データの出力 #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"; $s1->output_confidence_interval('1'); print "*****************************************************\n\n"; $s2->output_confidence_interval('2'); 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"; if($ttest->{equal_variance}) { print "\tequal variance assumption is accepted(not rejected) since F-statistic < cutoff F-statistic\n";} else { 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"; # Statistics::TTest::Sufficient の例 use Statistics::PointEstimation; use Statistics::TTest; my %sample1=( 'count' =>30, 'mean' =>3.98, 'variance' =>2.63 ); my %sample2=( 'count'=>30, 'mean'=>3.67, 'variance'=>1.12 ); my $ttest = new Statistics::TTest::Sufficient; $ttest->set_significance(90); $ttest->load_data(\%sample1,\%sample2); $ttest->output_t_test(); #$ttest->s1->print_confidence_interval(); $ttest->set_significance(99); $ttest->output_t_test(); #$ttest->s1->print_confidence_interval();
Statistics::TTest
本モジュールは2つの独立な標本に対する t-検定を行うモジュールである。測定点として2つの配列を取り、PointEstimation モジュール(これは本パッケージに同梱されている)を用いて信頼区間を計算し、T-統計量を用いて帰無仮説を検定する。帰無仮説が棄却されればその範囲は TTest オブジェクトの lower_clm 及び upper_clm として返す。
Statistics::TTest::Sufficient
本モジュールは Statistics::TTest のサブクラスである。入力として実際のデータを取る代わりに十分統計量と標本の大きさに基づく信頼区間を計算する。本モジュールを利用するためには標本の大きさ・標本平均・標本分散を load_data() 関数を用いて入力しなければならない。出力は厳密に Statistics::TTest モジュールのものと同じである。
Yun-Fang Juan , Yahoo! Inc. yunfang@yahoo-inc.com
Statistics::Descriptive, Statistics::Distributions, Statistics::PointEstimation
![]() |
Updated : 2007/02/26 |