[Bio] / FigKernelPackages / gjostat.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/gjostat.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Sun Aug 15 20:14:59 2010 UTC revision 1.3, Mon Dec 6 20:40:24 2010 UTC
# Line 1  Line 1 
1  package gjostat;  package gjostat;
2    
3  use strict;  use strict;
4    use Carp qw( confess );
5    
6  sub usage  sub usage
7  {  {
# Line 137  Line 138 
138  {  {
139      my ($xref, $yref) = @_;      my ($xref, $yref) = @_;
140      $xref && ref $xref eq 'ARRAY' && $yref && ref $yref eq 'ARRAY'      $xref && ref $xref eq 'ARRAY' && $yref && ref $yref eq 'ARRAY'
141          or die "gjostat::correl_coef() called with invalid parameter types.\n";          or confess "gjostat::correl_coef() called with invalid parameter types.\n";
142      (@$xref == @$yref) || die "gjostat::correl_coef() called with lists of different lengths\n";      (@$xref == @$yref) || confess "gjostat::correl_coef() called with lists of different lengths\n";
143      (@$xref > 2) || return undef;      (@$xref > 2) || return undef;
144      my (@x) = @$xref;      my (@x) = @$xref;
145      my (@y) = @$yref;      my (@y) = @$yref;
# Line 193  Line 194 
194      my $fr = shift;      my $fr = shift;
195      defined( $fr ) && ( $fr > 0 )      defined( $fr ) && ( $fr > 0 )
196                     && ( $fr < 1 )                     && ( $fr < 1 )
197                     || die "gjostat::general_median called with bad fraction: $fr\n";                     || confess "gjostat::general_median called with bad fraction: $fr\n";
198    
199      my $n = @_;      my $n = @_;
200      my $nbelow = $n * $fr;      my $nbelow = $n * $fr;
# Line 224  Line 225 
225  {  {
226      my ( $expect, $obs ) = @_;      my ( $expect, $obs ) = @_;
227      $expect && ref $expect eq 'ARRAY' && $obs && ref $obs eq 'ARRAY'      $expect && ref $expect eq 'ARRAY' && $obs && ref $obs eq 'ARRAY'
228          or die "gjostat::chi_square() called with invalid parameter types.";          or confess "gjostat::chi_square() called with invalid parameter types.";
229      ( @$expect > 1 ) && ( @$expect == @$obs ) || return ( 0, 0, 0 );      ( @$expect > 1 ) && ( @$expect == @$obs ) || return ( 0, 0, 0 );
230    
231      my ( $sum1, $sum2 ) = ( 0, 0 );      my ( $sum1, $sum2 ) = ( 0, 0 );
# Line 247  Line 248 
248          }          }
249          elsif ( $o > 0 )          elsif ( $o > 0 )
250          {          {
251              die "gjostat::chi_sqr called with invalid expected value\n"              confess "gjostat::chi_sqr called with invalid expected value\n"
252          }          }
253      }      }
254    
# Line 271  Line 272 
272    
273      ( @_ > 1 ) || return (0, 0, 0);      ( @_ > 1 ) || return (0, 0, 0);
274      ref( $_[0] ) eq "ARRAY"      ref( $_[0] ) eq "ARRAY"
275          || die "gjostat::contingency_chi_sqr: arguements must be ARRAY references\n";          || confess "gjostat::contingency_chi_sqr: arguements must be ARRAY references\n";
276    
277      my $ncol = @{ $_[0] };      my $ncol = @{ $_[0] };
278      my ( @rows, @csum, @rsum );      my ( @rows, @csum, @rsum );
# Line 282  Line 283 
283      foreach $row ( @_ )      foreach $row ( @_ )
284      {      {
285          ref( $row ) eq "ARRAY"          ref( $row ) eq "ARRAY"
286              || die "gjostat::contingency_chi_sqr: arguements must be ARRAY references\n";              || confess "gjostat::contingency_chi_sqr: arguements must be ARRAY references\n";
287          ( @$row == $ncol )          ( @$row == $ncol )
288              || die "gjostat::contingency_chi_sqr:  all rows must have same number of items\n";              || confess "gjostat::contingency_chi_sqr:  all rows must have same number of items\n";
289    
290          my $rsum = 0;          my $rsum = 0;
291          for (my $i = 0; $i < $ncol; $i++)          for (my $i = 0; $i < $ncol; $i++)
# Line 338  Line 339 
339         ) { @_ = @{$_[0]} }         ) { @_ = @{$_[0]} }
340    
341      ( @_ == 2 ) && ( ref( $_[0] ) eq "ARRAY" ) && ( ref( $_[1] ) eq "ARRAY" )      ( @_ == 2 ) && ( ref( $_[0] ) eq "ARRAY" ) && ( ref( $_[1] ) eq "ARRAY" )
342          || die "gjostat::contingency_chi_sqr_2:  requires two array references\n";          || confess "gjostat::contingency_chi_sqr_2:  requires two array references\n";
343    
344      my $ncol = @{ $_[0] };      my $ncol = @{ $_[0] };
345      ( $ncol == @{ $_[1] } )      ( $ncol == @{ $_[1] } )
346          || die "gjostat::contingency_chi_sqr_2:  all rows must have same number of items\n";          || confess "gjostat::contingency_chi_sqr_2:  all rows must have same number of items\n";
347    
348      my ( @csum, @rsum );      my ( @csum, @rsum );
349      my $sum = 0;      my $sum = 0;
# Line 403  Line 404 
404  {  {
405      my ($chisqr, $df) = @_;      my ($chisqr, $df) = @_;
406      defined($chisqr) && defined($df)      defined($chisqr) && defined($df)
407                || die "gjostat::chisqr_prob: undefined arguement\n";                || confess "gjostat::chisqr_prob: undefined arguement\n";
408    
409      ($chisqr >= 0)  || die "gjostat::chisqr_prob: bad chi square value: $chisqr\n";      ($chisqr >= 0)  || confess "gjostat::chisqr_prob: bad chi square value: $chisqr\n";
410      ($df > 0) && (int($df) == $df)      ($df > 0) && (int($df) == $df)
411                || die "gjostat::chisqr_prob: bad degrees of freedom: $df\n";                || confess "gjostat::chisqr_prob: bad degrees of freedom: $df\n";
412    
413      if ($chisqr == 0) { return 1 }      if ($chisqr == 0) { return 1 }
414      if ($chisqr - $df - 10*sqrt($df) > 49.0) { return 1e-14 }      if ($chisqr - $df - 10*sqrt($df) > 49.0) { return 1e-14 }
# Line 445  Line 446 
446    
447  sub chisqr_critical_value  sub chisqr_critical_value
448  {  {
449      ( 2 == @_ ) || die "gjostat::chisqr_critical_value called without 2 args\n";      ( 2 == @_ ) || confess "gjostat::chisqr_critical_value called without 2 args\n";
450      my ($prob, $df) = @_;      my ($prob, $df) = @_;
451    
452      ( $prob > 1e-13 ) && ( $prob < 1 )      ( $prob > 1e-13 ) && ( $prob < 1 )
453                        || die "gjostat::chisqr_critical_value:  chi square out of range: $prob\n";                        || confess "gjostat::chisqr_critical_value:  chi square out of range: $prob\n";
454    
455      ( $df > 0 ) && ( $df <= 200 )      ( $df > 0 ) && ( $df <= 200 )
456                  || die "gjostat::chisqr_critical_value:  df out of range: $df\n";                  || confess "gjostat::chisqr_critical_value:  df out of range: $df\n";
457    
458      my $chisqr = $df + 3 * sqrt($df);      my $chisqr = $df + 3 * sqrt($df);
459      my $step;      my $step;
# Line 488  Line 489 
489    
490  sub binomial_coef  sub binomial_coef
491  {  {
492      ( 2 == @_ ) || die "gjostat::binomial_coef called without 2 args\n";      ( 2 == @_ ) || confess "gjostat::binomial_coef called without 2 args\n";
493      my ($n, $m) = @_;      my ($n, $m) = @_;
494      ( $n >= 1 ) && ( $m >=  0 )      ( $n >= 1 ) && ( $m >=  0 )
495                  && ( $m <= $n )                  && ( $m <= $n )
496                  || die "gjostat::binomial_coef called with invalid arg values\n";                  || confess "gjostat::binomial_coef called with invalid arg values\n";
497      ( 2 * $m <= $n ) ? binomial_coef_1( $n, $m )      ( 2 * $m <= $n ) ? binomial_coef_1( $n, $m )
498                       : binomial_coef_1( $n, $n-$m );                       : binomial_coef_1( $n, $n-$m );
499  }  }
# Line 502  Line 503 
503    
504  sub binomial_prob_eq_m  sub binomial_prob_eq_m
505  {  {
506      ( 3 == @_ ) || die "gjostat::binomial_prob_eq_m called without 3 args\n";      ( 3 == @_ ) || confess "gjostat::binomial_prob_eq_m called without 3 args\n";
507      my ($n, $m, $p) = @_;      my ($n, $m, $p) = @_;
508      ( $n >= 1 ) && ( $m >=  0 )      ( $n >= 1 ) && ( $m >=  0 )
509                  && ( $m <= $n )                  && ( $m <= $n )
510                  && ( $p >=  0 )                  && ( $p >=  0 )
511                  && ( $p <=  1 )                  && ( $p <=  1 )
512                  || die "gjostat::binomial_prob_eq_m called with invalid arg values\n";                  || confess "gjostat::binomial_prob_eq_m called with invalid arg values\n";
513      if ( $p == 0 ) { return ($m ==  0) ? 1 : 0 }      if ( $p == 0 ) { return ($m ==  0) ? 1 : 0 }
514      if ( $p == 1 ) { return ($m == $n) ? 1 : 0 }      if ( $p == 1 ) { return ($m == $n) ? 1 : 0 }
515    
# Line 522  Line 523 
523    
524  sub binomial_prob_le_m  sub binomial_prob_le_m
525  {  {
526      ( 3 == @_ ) || die "gjostat::binomial_prob_le_m called without 3 args\n";      ( 3 == @_ ) || confess "gjostat::binomial_prob_le_m called without 3 args\n";
527      my ($n, $m, $p) = @_;      my ($n, $m, $p) = @_;
528      ( $n >= 1 ) && ( $m >=  0 )      ( $n >= 1 ) && ( $m >=  0 )
529                  && ( $m <= $n )                  && ( $m <= $n )
530                  && ( $p >=  0 )                  && ( $p >=  0 )
531                  && ( $p <=  1 )                  && ( $p <=  1 )
532                  || die "gjostat::binomial_prob_le_m called with invalid arg values\n";                  || confess "gjostat::binomial_prob_le_m called with invalid arg values\n";
533    
534      if ( ( $p == 0 ) || ( $m == $n ) ) { return 1 }      if ( ( $p == 0 ) || ( $m == $n ) ) { return 1 }
535      if (   $p == 1 ) { return 0 }    # special case of m == n handled above      if (   $p == 1 ) { return 0 }    # special case of m == n handled above
# Line 546  Line 547 
547    
548  sub binomial_prob_ge_m  sub binomial_prob_ge_m
549  {  {
550      ( 3 == @_ ) || die "gjostat::binomial_prob_ge_m called without 3 args\n";      ( 3 == @_ ) || confess "gjostat::binomial_prob_ge_m called without 3 args\n";
551      my ($n, $m, $p) = @_;      my ($n, $m, $p) = @_;
552      ( $n >= 1 ) && ( $m >=  0 )      ( $n >= 1 ) && ( $m >=  0 )
553                  && ( $m <= $n )                  && ( $m <= $n )
554                  && ( $p >=  0 )                  && ( $p >=  0 )
555                  && ( $p <=  1 )                  && ( $p <=  1 )
556                  || die "gjostat::binomial_prob_ge_m called with invalid arg values\n";                  || confess "gjostat::binomial_prob_ge_m called with invalid arg values\n";
557    
558      if ( ( $p == 1 ) || ( $m == 0 ) ) { return 1 }      if ( ( $p == 1 ) || ( $m == 0 ) ) { return 1 }
559      if (   $p == 0 ) { return 0 }        # special case of $m == 0 handled above      if (   $p == 0 ) { return 0 }        # special case of $m == 0 handled above
# Line 570  Line 571 
571    
572  sub ln_binomial_coef  sub ln_binomial_coef
573  {  {
574      ( 2 == @_ ) || die "gjostat::ln_binomial_coef called without 2 args\n";      ( 2 == @_ ) || confess "gjostat::ln_binomial_coef called without 2 args\n";
575      my ($n, $m) = @_;      my ($n, $m) = @_;
576      ( $n >= 1 ) && ( $m >=  0 )      ( $n >= 1 ) && ( $m >=  0 )
577                  && ( $m <= $n )                  && ( $m <= $n )
578                  || die "gjostat::ln_binomial_coef called with invalid arg values\n";                  || confess "gjostat::ln_binomial_coef called with invalid arg values\n";
579    
580      ( 2 * $m <= $n ) ? ln_binomial_coef_1($n, $m)      ( 2 * $m <= $n ) ? ln_binomial_coef_1($n, $m)
581                       : ln_binomial_coef_1($n, $n-$m);                       : ln_binomial_coef_1($n, $n-$m);
# Line 583  Line 584 
584    
585  sub ln_binomial_prob_eq_m  sub ln_binomial_prob_eq_m
586  {  {
587      ( 3 == @_ ) || die "gjostat::ln_binomial_prob_eq_m called without 3 args\n";      ( 3 == @_ ) || confess "gjostat::ln_binomial_prob_eq_m called without 3 args\n";
588      my ($n, $m, $p) = @_;      my ($n, $m, $p) = @_;
589      ( $n >= 1 ) && ( $m >=  0 )      ( $n >= 1 ) && ( $m >=  0 )
590                  && ( $m <= $n )                  && ( $m <= $n )
591                  && ( $p >=  0 )                  && ( $p >=  0 )
592                  && ( $p <=  1 )                  && ( $p <=  1 )
593                  || die "gjostat::ln_binomial_prob_eq_m called with invalid arg values\n";                  || confess "gjostat::ln_binomial_prob_eq_m called with invalid arg values\n";
594      if ( $p == 0 ) { return ($m ==  0) ? 0 : undef }      if ( $p == 0 ) { return ($m ==  0) ? 0 : undef }
595      if ( $p == 1 ) { return ($m == $n) ? 0 : undef }      if ( $p == 1 ) { return ($m == $n) ? 0 : undef }
596    
# Line 601  Line 602 
602    
603  sub binomial_critical_value_m_ge  sub binomial_critical_value_m_ge
604  {  {
605      ( 3 == @_ ) || die "gjostat::binomial_critical_value_m_ge called without 3 args\n";      ( 3 == @_ ) || confess "gjostat::binomial_critical_value_m_ge called without 3 args\n";
606      my ($n, $p, $P) = @_;      my ($n, $p, $P) = @_;
607      ( $n >= 1 ) && ( $P >  0 )      ( $n >= 1 ) && ( $P >  0 )
608                  && ( $P <= 1 )                  && ( $P <= 1 )
609                  && ( $p >= 0 )                  && ( $p >= 0 )
610                  && ( $p <  1 )                  && ( $p <  1 )
611                  || die "gjostat::binomial_critical_value_m_ge called with invalid arg values\n";                  || confess "gjostat::binomial_critical_value_m_ge called with invalid arg values\n";
612      if ( $P == 1 ) { return 0 }      if ( $P == 1 ) { return 0 }
613      if ( $p == 0 ) { return 1 }      if ( $p == 0 ) { return 1 }
614    
# Line 630  Line 631 
631    
632  sub binomial_critical_value_m_le  sub binomial_critical_value_m_le
633  {  {
634      ( 3 == @_ ) || die "gjostat::binomial_critical_value_m_le called without 3 args\n";      ( 3 == @_ ) || confess "gjostat::binomial_critical_value_m_le called without 3 args\n";
635      my ($n, $p, $P) = @_;      my ($n, $p, $P) = @_;
636      ( $n >= 1 ) && ( $P >  0 )      ( $n >= 1 ) && ( $P >  0 )
637                  && ( $P <= 1 )                  && ( $P <= 1 )
638                  && ( $p >  0 )                  && ( $p >  0 )
639                  && ( $p <= 1 )                  && ( $p <= 1 )
640                  || die "gjostat::binomial_critical_value_m_le called with invalid arg values\n";                  || confess "gjostat::binomial_critical_value_m_le called with invalid arg values\n";
641      if ($P == 1) { return $n }      if ($P == 1) { return $n }
642      if ($p == 1) { return $n-1 }      if ($p == 1) { return $n-1 }
643    
# Line 809  Line 810 
810    
811  sub binomial_prob_le_m_slower  sub binomial_prob_le_m_slower
812  {  {
813      ( 3 == @_ ) || die "gjostat::binomial_prob_le_m_slower called without 3 args\n";      ( 3 == @_ ) || confess "gjostat::binomial_prob_le_m_slower called without 3 args\n";
814      my ($n, $m, $p) = @_;      my ($n, $m, $p) = @_;
815      ( $n >= 1 ) && ( $m >=  0 )      ( $n >= 1 ) && ( $m >=  0 )
816                  && ( $m <= $n )                  && ( $m <= $n )
817                  && ( $p >=  0 )                  && ( $p >=  0 )
818                  && ( $p <=  1 )                  && ( $p <=  1 )
819                  || die "gjostat::binomial_prob_lbinomial_prob_le_m_slowere_m called with invalid arg values\n";                  || confess "gjostat::binomial_prob_lbinomial_prob_le_m_slowere_m called with invalid arg values\n";
820    
821      if ( ( $p == 0 ) || ( $m == $n ) ) { return 1 }      if ( ( $p == 0 ) || ( $m == $n ) ) { return 1 }
822      if (   $p == 1 ) { return 0 }    # special case of m == n handled above      if (   $p == 1 ) { return 0 }    # special case of m == n handled above
# Line 836  Line 837 
837    
838  sub binomial_prob_ge_m_slower  sub binomial_prob_ge_m_slower
839  {  {
840      ( 3 == @_ ) || die "gjostat::binomial_prob_ge_m_slower called without 3 args\n";      ( 3 == @_ ) || confess "gjostat::binomial_prob_ge_m_slower called without 3 args\n";
841      my ($n, $m, $p) = @_;      my ($n, $m, $p) = @_;
842      ( $n >= 1 ) && ( $m >=  0 )      ( $n >= 1 ) && ( $m >=  0 )
843                  && ( $m <= $n )                  && ( $m <= $n )
844                  && ( $p >=  0 )                  && ( $p >=  0 )
845                  && ( $p <=  1 )                  && ( $p <=  1 )
846                  || die "gjostat::binomial_prob_ge_m_slower called with invalid arg values\n";                  || confess "gjostat::binomial_prob_ge_m_slower called with invalid arg values\n";
847    
848      if ( ( $p == 1 ) || ( $m == 0 ) ) { return 1 }      if ( ( $p == 1 ) || ( $m == 0 ) ) { return 1 }
849      if (   $p == 0 ) { return 0 }        # special case of $m == 0 handled above      if (   $p == 0 ) { return 0 }        # special case of $m == 0 handled above
# Line 863  Line 864 
864    
865  sub binomial_prob_le_m_slowest  sub binomial_prob_le_m_slowest
866  {  {
867      ( 3 == @_ ) || die "gjostat::binomial_prob_le_m_slowest called without 3 args\n";      ( 3 == @_ ) || confess "gjostat::binomial_prob_le_m_slowest called without 3 args\n";
868      my ($n, $m, $p) = @_;      my ($n, $m, $p) = @_;
869      ( $n >= 1 ) && ( $m >=  0 )      ( $n >= 1 ) && ( $m >=  0 )
870                  && ( $m <= $n )                  && ( $m <= $n )
871                  && ( $p >=  0 )                  && ( $p >=  0 )
872                  && ( $p <=  1 )                  && ( $p <=  1 )
873                  || die "gjostat::binomial_prob_le_m_slowest called with invalid arg values\n";                  || confess "gjostat::binomial_prob_le_m_slowest called with invalid arg values\n";
874    
875      if ( ( $p == 0 ) || ( $m == $n ) ) { return 1 }      if ( ( $p == 0 ) || ( $m == $n ) ) { return 1 }
876      if (   $p == 1 ) { return 0 }    # special case of m == n handled above      if (   $p == 1 ) { return 0 }    # special case of m == n handled above
# Line 886  Line 887 
887    
888  sub binomial_prob_ge_m_slowest  sub binomial_prob_ge_m_slowest
889  {  {
890      ( 3 == @_ ) || die "gjostat::binomial_prob_ge_m_slowest called without 3 args\n";      ( 3 == @_ ) || confess "gjostat::binomial_prob_ge_m_slowest called without 3 args\n";
891      my ($n, $m, $p) = @_;      my ($n, $m, $p) = @_;
892      ( $n >= 1 ) && ( $m >=  0 )      ( $n >= 1 ) && ( $m >=  0 )
893                  && ( $m <= $n )                  && ( $m <= $n )
894                  && ( $p >=  0 )                  && ( $p >=  0 )
895                  && ( $p <=  1 )                  && ( $p <=  1 )
896                  || die "gjostat::binomial_prob_ge_m_slowest called with invalid arg values\n";                  || confess "gjostat::binomial_prob_ge_m_slowest called with invalid arg values\n";
897    
898      if ( ( $p == 1 ) || ( $m == 0 ) ) { return 1 }      if ( ( $p == 1 ) || ( $m == 0 ) ) { return 1 }
899      if (   $p == 0 ) { return 0 }        # special case of $m == 0 handled above      if (   $p == 0 ) { return 0 }        # special case of $m == 0 handled above
# Line 911  Line 912 
912    
913  sub std_normal_le_z  sub std_normal_le_z
914  {  {
915      ( 1 == @_ ) || die "gjostat::std_normal_le_z called without 1 arg\n";      ( 1 == @_ ) || confess "gjostat::std_normal_le_z called without 1 arg\n";
916      my ($z) = @_;      my ($z) = @_;
917      ($z <= 0) ?     std_normal_le_z_1( $z)      ($z <= 0) ?     std_normal_le_z_1( $z)
918                : 1 - std_normal_le_z_1(-$z);                : 1 - std_normal_le_z_1(-$z);
# Line 922  Line 923 
923    
924  sub std_normal_ge_z  sub std_normal_ge_z
925  {  {
926      ( 1 == @_ ) || die "gjostat::std_normal_ge_z called without 1 arg\n";      ( 1 == @_ ) || confess "gjostat::std_normal_ge_z called without 1 arg\n";
927      my ($z) = @_;      my ($z) = @_;
928      ($z >= 0) ?     std_normal_le_z_1(-$z)      ($z >= 0) ?     std_normal_le_z_1(-$z)
929                : 1 - std_normal_le_z_1( $z);                : 1 - std_normal_le_z_1( $z);
# Line 959  Line 960 
960    
961  sub std_normal_critical_value_z_ge  sub std_normal_critical_value_z_ge
962  {  {
963      ( 1 == @_ ) || die "gjostat::std_normal_critical_value_z_ge called without 1 arg\n";      ( 1 == @_ ) || confess "gjostat::std_normal_critical_value_z_ge called without 1 arg\n";
964      my ($P) = @_;      my ($P) = @_;
965      ( $P > 0 ) && ( $P < 1 )      ( $P > 0 ) && ( $P < 1 )
966                 ||  die "gjostat::std_normal_critical_value_z_ge argument out of range\n";                 ||  confess "gjostat::std_normal_critical_value_z_ge argument out of range\n";
967      ( $P <= 0.5 ) ?  std_normal_critical_value_z_ge_2(     $P )      ( $P <= 0.5 ) ?  std_normal_critical_value_z_ge_2(     $P )
968                    : -std_normal_critical_value_z_ge_2( 1 - $P )                    : -std_normal_critical_value_z_ge_2( 1 - $P )
969  }  }
# Line 972  Line 973 
973    
974  sub std_normal_critical_value_z_le  sub std_normal_critical_value_z_le
975  {  {
976      ( 1 == @_ ) || die "gjostat::std_normal_critical_value_z_le called without 1 arg\n";      ( 1 == @_ ) || confess "gjostat::std_normal_critical_value_z_le called without 1 arg\n";
977      my ($P) = @_;      my ($P) = @_;
978      ( $P > 0 ) && ( $P < 1 )      ( $P > 0 ) && ( $P < 1 )
979                 ||  die "gjostat::std_normal_critical_value_z_le argument out of range\n";                 ||  confess "gjostat::std_normal_critical_value_z_le argument out of range\n";
980    
981      ( $P <= 0.5 ) ? -std_normal_critical_value_z_ge_2(     $P )      ( $P <= 0.5 ) ? -std_normal_critical_value_z_ge_2(     $P )
982                    :  std_normal_critical_value_z_ge_2( 1 - $P )                    :  std_normal_critical_value_z_ge_2( 1 - $P )
# Line 1125  Line 1126 
1126    
1127  sub  poisson_prob_eq_n  sub  poisson_prob_eq_n
1128  {  {
1129      ( 2 == @_ ) || die "gjostat::poisson_prob_eq_n called without 2 args\n";      ( 2 == @_ ) || confess "gjostat::poisson_prob_eq_n called without 2 args\n";
1130      my ($n, $mu) = @_;      my ($n, $mu) = @_;
1131      ( $n >= 0 ) && ( $mu >= 0 )      ( $n >= 0 ) && ( $mu >= 0 )
1132                  || die "gjostat::poisson_prob_eq_n called with invalid arg values\n";                  || confess "gjostat::poisson_prob_eq_n called with invalid arg values\n";
1133    
1134      #  Figure out the most effective approach      #  Figure out the most effective approach
1135    
# Line 1139  Line 1140 
1140    
1141  sub  poisson_prob_le_n  sub  poisson_prob_le_n
1142  {  {
1143      ( 2 == @_ ) || die "gjostat::poisson_prob_le_n called without 2 args\n";      ( 2 == @_ ) || confess "gjostat::poisson_prob_le_n called without 2 args\n";
1144      my ($n, $mu) = @_;      my ($n, $mu) = @_;
1145      ( $n >= 0 ) && ( $mu >= 0 )      ( $n >= 0 ) && ( $mu >= 0 )
1146                  || die "gjostat::poisson_prob_le_n called with invalid arg values\n";                  || confess "gjostat::poisson_prob_le_n called with invalid arg values\n";
1147    
1148      #  Figure out the most effective approach      #  Figure out the most effective approach
1149    
# Line 1155  Line 1156 
1156    
1157  sub  poisson_prob_ge_n  sub  poisson_prob_ge_n
1158  {  {
1159      ( 2 == @_ ) || die "gjostat::poisson_prob_ge_n called without 2 args\n";      ( 2 == @_ ) || confess "gjostat::poisson_prob_ge_n called without 2 args\n";
1160      my ($n, $mu) = @_;      my ($n, $mu) = @_;
1161      ( $n >= 0 ) && ( $mu >= 0 )      ( $n >= 0 ) && ( $mu >= 0 )
1162                  || die "gjostat::poisson_prob_ge_n called with invalid arg values\n";                  || confess "gjostat::poisson_prob_ge_n called with invalid arg values\n";
1163    
1164      #  Figure out the most effective approach      #  Figure out the most effective approach
1165    
# Line 1206  Line 1207 
1207    
1208  sub  factorial  sub  factorial
1209  {  {
1210      ( 1 == @_ ) || die "gjostat::factorial called without 1 arg\n";      ( 1 == @_ ) || confess "gjostat::factorial called without 1 arg\n";
1211      my $n = shift;      my $n = shift;
1212      ( $n >= 0 ) && ( $n <= 170)      ( $n >= 0 ) && ( $n <= 170)
1213                  || die "gjostat::factorial called with out of range argument\n";                  || confess "gjostat::factorial called with out of range argument\n";
1214    
1215      factorial_0( $n );      factorial_0( $n );
1216  }  }
# Line 1233  Line 1234 
1234    
1235  sub  ln_factorial  sub  ln_factorial
1236  {  {
1237      ( 1 == @_ ) || die "gjostat::ln_factorial called without 1 arg\n";      ( 1 == @_ ) || confess "gjostat::ln_factorial called without 1 arg\n";
1238      my $n = shift;      my $n = shift;
1239      ( $n >= 0 ) && ( $n <= 1e7)      ( $n >= 0 ) && ( $n <= 1e7)
1240                  || die "gjostat::ln_factorial called with out of range argument\n";                  || confess "gjostat::ln_factorial called with out of range argument\n";
1241    
1242      ln_factorial_0( $n );      ln_factorial_0( $n );
1243  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3