Win has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

The following bit of Perl:

use strict; use DBI; use DBD::ODBC; use Statistics::Distributions; ### A load of code here ### And then: while ( my @columns = $sthZL->fetchrow() ) { print " Row " . $count++ . ":" . join("\t",@columns) . "\n" +; my $degrees_of_freedom_in_numerator = 2*($columns[4]-$columns[ +6]+1); my $degrees_of_freedom_in_denominator = 2*($columns[6]); my $fprob=Statistics::Distributions::fprob($degrees_of_freedom +_in_numerator, $degrees_of_freedom_in_denominator, 0.025); my $result = ($columns[3]+(sqrt(($columns[6]/1000)/$columns[4] +)*($columns[4]/$columns[4]+($columns[5]-$columns[4]+1)*$fprob*$column +s[4]-$columns[3]))*100000); print "\n$result\n";
Gives me:
<code> Row 1:All All 459 7236 286820 3000 .0103270000000 +00000000000000 Invalid n: 573641.979346
Can anyone please explain 'Invalid n' error message?

janitored by ybiC: Retitle from "Invalid n - error message" for better searching

Replies are listed 'Best First'.
Re: Statistics::Distributions, error "Invalid n:"
by idsfa (Vicar) on Feb 04, 2004 at 16:33 UTC

    Did you look at the docs for Statistics::Distributions? Or the code? If you had, you would see that fprob only accepts positive integer values for the degrees of freedom (as it should).

    sub fprob { # Upper probability F(x,n1,n2) my ($n, $m, $x) = @_; if (($n<=0) || ((abs($n)-(abs(int($n))))!=0)) { die "Invalid n: $n\n"; # first degree of freedom } if (($m<=0) || ((abs($m)-(abs(int($m))))!=0)) { die "Invalid m: $m\n"; # second degree of freedom } return precision_string(_subfprob($n, $m, $x)); }

    If anyone needs me I'll be in the Angry Dome.
Re: Statistics::Distributions, error "Invalid n:"
by Old_Gray_Bear (Bishop) on Feb 04, 2004 at 16:29 UTC
    It has been a while since I did semi-serious statistics. But, shouldn't the 'degrees of freedom' be intergers? The DoF in the denominator works out to 2*0.10327....

    ----
    I Go Back to Sleep, Now.

    OGB