Tag: apache commons math

计算t-inverse

我试图用commons-math来计算2尾学生分布的倒数。 我正在使用Excel来比较值,并validation我的结果是否正确。 所以用excel来计算5个自由度和95.45%的TINV =TINV(0.0455,5) 并得到结果:2.64865 使用普通的math就像这样: TDistribution t = new TDistribution(5); double value = t.inverseCumulativeProbability(0.9545); 我得到结果:2.08913 我可能显然做错了什么。 我并不是那个精通math的人,但是我需要将一个Excel工作表的公式移植到一个项目的Java中,并且陷入了这个困境。 我应该用什么来得到像TINV值一样的结果? 我错过了什么。

使用Apache Commons库计算TDIST

我正在试图用commons-math来计算一个2尾的学生分布。 我正在使用Excel来比较值,并validation我的结果是否正确。 所以使用excel来计算TDIST(x,df,t),其中x = 5.968191467,df = 8,tail t = 2 =TDIST(ABS(5.968191467),8,2) 并得到结果:0.000335084 使用普通的math就像这样: TDistribution tDistribution = new TDistribution(8); System.out.println(BigDecimal.valueOf(tDistribution.density(5.968191467))); 我得到结果:0.00018738010608336254 我应该用什么来得到像TDIST值一样的结果?

百分点计算不匹配使用apache.math3.stat.descriptive

我正在计算以下数字列表的第95个百分点: 66,337.8,989.7,1134.6,1118.7,1097.9,1122.1,1121.3,1106.7,871,325.2,285.1,264.1,295.8,342.4 apache库使用NIST标准来计算与Excel使用的方法相同的百分位数。 根据Excel,以上列表的第95百分位应该是1125.85。 但是,使用下面的代码,我得到了一个不同的结果: DescriptiveStatistics shortList = new DescriptiveStatistics(); @BeforeTest @Parameters("shortStatsList") private void buildShortStatisticsList(String list) { StringTokenizer tokens = new StringTokenizer(list, ","); while (tokens.hasMoreTokens()) { shortList.addValue(Double.parseDouble(tokens.nextToken())); } } @Test @Parameters("95thPercentileShortList") public void percentileShortListTest(String percentile) { Assert.assertEquals(Double.toString(shortList.getPercentile(95)), percentile); } 这会失败并显示以下消息: java.lang.AssertionError: expected:<1125.85> but was:<1134.6> at org.testng.Assert.fail(Assert.java:89) at org.testng.Assert.failNotEquals(Assert.java:489) 1134.6是列表中的最大值,而不是第95百分位,所以我不知道这个值来自哪里。