How does one use empirical distributions?


#1

dear stats experts—the following used to work.

julia> using Random, Distributions; Random.seed!(0);

julia> x=  max.(randn(10000), (rand(10000) .- 0.5));

julia> empcdfun= EmpiricalUnivariateDistribution( x );

julia> cdf.( empcdfun, [-0.5,-0.25,0.0,0.5, 10.0] )
5-element Array{Float64,1}:
 0.0
 0.0998
 0.2453
 0.6972
 1.0

but no longer… :frowning:

ERROR: MethodError: Cannot `convert` an object of type StatsBase.ECDF{Array{Float64,1}} to an object of type Function
Closest candidates are:
  convert(::Type{T}, ::T) where T at essentials.jl:154

There is also no example in the ‘?EmpiricalUnivariateDistribution’ internal docs. Could someone please provide a short example?

regards,

/iaw


#2

The short answer is you don’t.