I am looking for a java library / implementation that supports the calculation of the inverse cumulative distribution function for a beta distribution (aka quantile estimation) with reasonable accuracy .
Of course, I tried apache commons math , but in version 3 there are still some problems with accuracy . Below, the problem that leads to this issue is described in detail.
Suppose I want to calculate the confidence interval of a beta distribution with a large number of samples. In apache commons math ...
final int trials = 161750;
final int successes = 10007;
final double alpha = 0.05d;
BetaDistribution betaDist = new BetaDistribution(successes + 1, trials - successes + 1, 1e-9);
System.out.println("2.5 percentile :" + betaDist.inverseCumulativeProbability(alpha / 2d));
System.out.println("mean: " + betaDist.getNumericalMean());
System.out.println("median: " + betaDist.inverseCumulativeProbability(0.5));
System.out.println("97.5 percentile :" + betaDist.inverseCumulativeProbability(1 - alpha / 2d));
which provides
2.5 percentile :0.062030402074808505
mean: 0.06187249616697166
median: 0.062030258659508855
97.5 percentile :0.06305170793994147
The problems are that 2.5 percentiles and medians coincide with each other, both average and average.
For comparison, an R-packet bean delivers
binom.confint(10007+1,161750+2,methods=c("agresti-coull","exact","wilson"))
method x n mean lower upper
1 agresti-coull 10008 161752 0.0618725 0.06070873 0.06305707
2 exact 10008 161752 0.0618725 0.06070317 0.06305756
3 wilson 10008 161752 0.0618725 0.06070877 0.06305703
R-
qbeta(c(0.025,0.975),10007+1,161750-10007+1)
[1] 0.06070355 0.06305171
R,
:
- . , 1 ( 41 ( ) apache commons math).
- , R java. , , , - ( java) .
21.08.12
,, , , 3.1-SNAPSHOT apache-commons-math. usecase
2.5 percentile :0.06070354581340706
mean: 0.06187249616697166
median: 0.06187069085946604
97.5 percentile :0.06305170793994147
23.02.13
, , , () what-first-come-to-mind-hacker. , .