Distributions.jl icon indicating copy to clipboard operation
Distributions.jl copied to clipboard

KSDist is broken

Open mohdibntarek opened this issue 6 years ago • 6 comments

julia> using Distributions

julia> logpdf(KSDist(1), 0.5)
ERROR: MethodError: no method matching pdf(::KSDist, ::Float64)
Closest candidates are:
  pdf(::Chernoff, ::Real) at C:\Users\user\.julia\packages\Distributions\wRw5p\src\univariate\continuous\chernoff.jl:168
  pdf(::Kolmogorov, ::Real) at C:\Users\user\.julia\packages\Distributions\wRw5p\src\univariate\continuous\kolmogorov.jl:81
  pdf(::DiscreteNonParametric{T,P,Ts,Ps} where Ps<:AbstractArray{P,1} where Ts<:AbstractArray{T,1} where P<:Real, ::Real) where T at C:\Users\user\.julia\packages\Distributions\wRw5p\src\univariate\discrete\discretenonparametric.jl:108
  ...
Stacktrace:
 [1] logpdf(::KSDist, ::Float64) at C:\Users\user\.julia\packages\Distributions\wRw5p\src\univariates.jl:342
 [2] top-level scope at none:0

mohdibntarek avatar Oct 05 '19 04:10 mohdibntarek

I don't think the pdf for this distribution is even known. But if it is, I don't see it in here. So it's not that it's broken. It just hasn't been implemented (because I don't think we know the pdf).

johnczito avatar Oct 05 '19 04:10 johnczito

Thanks for your comment. If that's the case, then perhaps a better error message will be nice.

mohdibntarek avatar Oct 05 '19 04:10 mohdibntarek

The error message you got is telling you the right thing -- that the method is not implemented. But it doesn't tell you why. So you want something like this?

pdf(d::KSDist, x::Real) = error("The pdf of the Kolmogorov distribution is not known.")

johnczito avatar Oct 05 '19 06:10 johnczito

Yes I think this would be better.

mohdibntarek avatar Oct 05 '19 07:10 mohdibntarek

We could have a custom UnknownFunction error that we throw for these things.

matbesancon avatar Oct 19 '19 08:10 matbesancon

I'm sorry to bring back to life this discussion after 4 years, but even if the analytical form of the pdf of the KSDist distribution is not known, it can be derived from the cdf.

Shouldn't we implement it?

pviscone avatar Oct 02 '23 14:10 pviscone