开发者

Does Statistics::Descriptive percentile method work as documented?

use strict;
use warnings;
use Statistics::Descriptive;
use 5.012;

my @data = ( -2, 7, 7, 4, 18, -5 );
my $stat = Statistics::Descriptive::Full->new();
$stat->add_data(@data);
say ($stat->percentile(100) // "undef"); # return 18. OK.
say ($stat->percentile(0) // "undef"); # return undef instead of "-inf". see doc below

Statistics::Desc开发者_运维技巧riptive doc.


Same outcome on ActiveState 5.12.2 64-bit on a Windows platform. You answered your own question: it does not work as documented.

#!/usr/bin/perl -w
use strict;
use warnings;
use Statistics::Descriptive;
use Math::Bigint;

use 5.012;

my @data = ( -2, 7, 7, 4, 18, -5 );
my $stat = Statistics::Descriptive::Full->new();
$stat->add_data(@data);
say(Math::BigInt->is_inf($stat->percentile(0)));

returns 0

Edit : as rafl points out, on a Windows system perl -e "print(9**9**9);" will give 1.#INF instead of inf. As inf apparently isn't implemented yet in my version, the Statistics package won't be able to return inf and returns undefined instead.

Edit2 : As it turns out OP works on Linux and can return inf, the error is probably inherent to the Statistics::Descriptive package.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜