Java Apache Commons getPercentile()不同的结果,MS Excel的百分位数 [英] Java Apache Commons getPercentile() different result that MS Excel percentile

查看:620
本文介绍了Java Apache Commons getPercentile()不同的结果,MS Excel的百分位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个算法计算一系列值的$ code百分位数(85)与 Apache Commons 值),以便稍后进行评估,并作出决定。结果类似于Excel给出的结果,但不等于,有时这对我的应用程序至关重要,因为使用excel的结果不会超过阈值,并且Apache Commons Math在 Java 这样做,所以我得到不同的输出。



这是一个例子:每2小时互联网流量(Mbps)


32,7076813360000000 41,2580429776000000 45,4453940200000000 48,8044409456000000 46,7462847936000000 49,8028100056000000 54,3719451144000000 41,3708134600000000 29,4371963240000000 22,4667255616000000 20,0388452248000000 28,7807757104000000


除以1000 Mb(电缆的容量),我计算占用的百分比(85):

Excel: 0,049153870117



Apache Commons数学:0.05003126676104001



我发现有可能改变使用 setPercentileImpl()的百分位数(它不存在),但是我找不到任何如何执行此操作的示例,或者Excel算法我被告知要实现的那个)。



任何有关这方面的帮助将受到欢迎。



谢谢。

解决方案

解决方案是创建一个类 PercentileExcel ,它几乎是从commons方法的百分位数的副本,除了如何计算位置的一个小的变化:

  POS =(1 + p *(N-1))/ 100; 

然后,您需要将该行添加到代码中才能使用新类百分比:

  setPercentileImpl(PercentileExcel); 


I have an algorithm that calculates the percentile(85) with Apache Commons of a series of values (12 values), for a later evaluation with a threshold to make a decision. The result is similar to the one given by Excel, but not equal, and sometimes this is critical for my application because with excel the result doesn't pass the threshold and with Apache Commons Math in Java it does, so I get different outputs.

Here it is an example: Internet traffic (Mbps) every 2 hours

32,7076813360000000 41,2580429776000000 45,4453940200000000 48,8044409456000000 46,7462847936000000 49,8028100056000000 54,3719451144000000 41,9708134600000000 29,4371963240000000 22,4667255616000000 20,0388452248000000 28,7807757104000000

After dividing by 1000 Mb (the capacity of the cable) I calculate the percentil(85) of the Occupation:

Excel: 0,049153870117

Apache Commons Math: 0.05003126676104001

I have found that it is possible to change the implementation of the percentile (it does not exist an official one) with setPercentileImpl(), but I couldn't find any example of how to do this, or the Excel algorithm (which is the one I was told to achieve).

Any help about this will be welcomed.

Thank you.

解决方案

The solution was creating a class PercentileExcel which is almost a copy of percentile from commons method except for a small change on how to caculate the position:

pos=(1+p*(n-1))/100;

Then you need to add this line to the code in order to use the new class for percentile:

setPercentileImpl(PercentileExcel);

这篇关于Java Apache Commons getPercentile()不同的结果,MS Excel的百分位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆