Perl 统计学::描述性百分位数方法是否如文件所述有效?
在Windows平台上的ActiveState 5.12.2 64位上的结果相同。您回答了自己的问题:它没有按照文档记录的那样工作Perl 统计学::描述性百分位数方法是否如文件所述有效?,perl,statistics,Perl,Statistics,在Windows平台上的ActiveState 5.12.2 64位上的结果相同。您回答了自己的问题:它没有按照文档记录的那样工作 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); sa
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
返回0
编辑:正如rafl指出的,在Windows系统上,perl-e“print(9**9**9);”
将给出1.#INF
而不是INF
。由于inf
显然尚未在我的版本中实现,因此统计数据包将无法返回inf
,而是返回未定义
Edit2:由于OP在Linux上工作并且可以返回
inf
,这个错误可能是Statistics::Descriptive
包固有的。请注意,win32上的C库将包含无限或不包含数字的双精度格式设置为1.\inf
,-1.\inf
,1.\QNAN
和-1.\IND,而不是像大多数Unix平台所期望的那样,使用inf
、-inf
、nan
和-nan
Math::BigInt
sis_-inf
和is_-nan
方法还不能解决这个问题(尽管在perl核心和Math::BigInt
中修复这个问题的工作正在进行中)。@rafl:感谢您的澄清。我已经注意到了,我很确定OP也运行Windows。这就是为什么百分位函数给出这个结果的原因。但是除非OP说明他的设置是什么,否则这不能确定。我实际上运行的是linux(Ubuntu和CentOS)@David B:只要做一下测试:如果perl-e“print(9**9**9);“
没有返回inf,那么这就是问题的原因。否则,在统计模块的实现中会出现其他问题。@David:这就排除了与平台相关的问题。所以我想这实际上是在实现本身。报告的Thx。请将此报告为CPAN上的错误。如果您还包括一个测试,可能是作为现有t/descr.t
test的补丁,那么它很快就会被修复。@toolic
#!/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)));