From:

Date:

March 15, 2002 04:25Subject:

Trouble with Math::NumberCruncherMessage ID:

Pine.OSF.4.10.10203151748260.474791-100000@brahma.igidr.ac.inThis might seem trivial, but it has me stumped. The variance of numbers 0..20 is 38.5. Then why does Math:NumberCruncher show it as 36.6667? Here's a sample prog, and it's output. Here test04.dat is a file that has numbers 0 to 20, on separate lines. #-------------------start---------------- #!/usr/bin/perl -w use Math::NumberCruncher; # Program to test Math::NumberCruncher # Get a file from STDIN, print the variance, and the std. deviation. @array = <>; map {chomp} @array; $variance = Math::NumberCruncher::Variance(\@array); $stddev = Math::NumberCruncher::StandardDeviation(\@array); $sd2 = $stddev**2; print scalar(@array), "\n"; printf "Var=$variance, S.D=$stddev S.D^2 = $sd2\n"; exit; #----------------end--------------------- And the output is: 21 Var=36.6666666666667, S.D=6.05530070819498 S.D^2 = 36.6666666666667 What could be possibly wrong? Even the standard value is wrong. TIA, -tir -- Tirthankar, IGIDR. +91-22-8400919 x275 (r), x593(o), x542(CFL). http://www.igidr.ac.in/~tir LEGACY, n. A gift from one who is legging it out of this vale of tears.Thread Next

**Trouble with Math::NumberCruncher**by Tirthankar C. Patnaik- Re: Trouble with Math::NumberCruncher by Nick_D_Montpetit
- Re: Trouble with Math::NumberCruncher by John W. Krahn

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About