JuliaStats / Distributions.jl

A Julia package for probability distributions and associated functions.
Other
1.11k stars 415 forks source link

Implement `quantile()` for `KSDist(n)` and `KSOneSided(n)` #718

Open JLTastet opened 6 years ago

JLTastet commented 6 years ago

KSDist(n) and KSOneSided(n) currently do not provide a method for the quantile(d,q) function.

It seems that it could be done using the @quantile_newton macro since these distributions both implement cdf(). Would that be doable or is there a good reason why this is not done ?

JLTastet commented 6 years ago

Ok, I had a look at the source, and it seems that we would need to implement pdf() and mode() first.

I tried implementing pdf() using automatic differentiation. Unfortunately, ccdf(d::KSOneSided, x::Float64) ultimately relies on rmath.jl for binompdf, so autodiff will not work.

Regarding KSDist, the situation seems a bit better. cdf_durbin() could in principle work if ForwardDiff.Dual implemented the big() function. This should be straightforward to do. However, ccdf_miller() calls ccdf(d::KSOneSided, x), so we end up with the same problem as before.

JLTastet commented 6 years ago

Alternatively, quantile_bisect() seems to work fine with these two distributions.

Probably not the fastest nor the most accurate solution, but at least for me it will do the job.

longemen3000 commented 4 years ago

bumped