EmpiricalCDFs.EmpiricalCDFsModule
module EmpiricalCDFs

Build and use empirical cumulative distribution functions.

Types/constructors: AbstractEmpiricalCDF, EmpiricalCDF, EmpiricalCDFHi

Functions/methods: Many of the methods defined for AbstractEmpiricalCDF are forwarded to the underlying array.

logprint, linprint, length, counts, sort!, issorted, empty!, mean, median, middle, minimum, maximum, extrema, std, stdm, var, varm, quantile, iterate

The statistical methods extend functions in Statistics. One way to use them with EmpiricalCDFs is using Statistics.

Binary IO is supported by the submodule EmpiricalCDFs.IOcdf.

EmpiricalCDFs.EmpiricalCDFMethod
EmpiricalCDF(lowreject::Real)

If lowreject is finite return EmpiricalCDFHi(lowreject). Otherwise return EmpiricalCDF().

EmpiricalCDFs.EmpiricalCDFMethod
EmpiricalCDF{T=Float64}()

Construct an empirical CDF. After inserting elements with push! or append!, and before using most of the functions below, the CDF must be sorted with sort!.

EmpiricalCDF and EmpiricalCDFHi are callable objects. For cdf::AbstractEmpiricalCDF, cdf(x) returns the estimate of the CDF at x. By contrast, cdf[inds] indexes into the underlying data array.

julia> cdf = EmpiricalCDF();
julia> append!(cdf,randn(10^6));
julia> sort!(cdf);
julia> cdf(0.0)
0.499876
julia> cdf(1.0)
0.840944
julia> cdf(-1.0)
0.158494

In this example, we collected $10^6$ samples from the unit normal distribution. About half of the samples are greater than zero. Approximately the same mass is between zero and one as is between zero and minus one.

EmpiricalCDFs.EmpiricalCDFHiType
EmpiricalCDFHi{T <: Real} <: AbstractEmpiricalCDF

Empirical CDF with lower cutoff. That is, keep only the tail.

EmpiricalCDFs.EmpiricalCDFHiMethod
EmpiricalCDFHi(lowreject::Real)

Return a CDF that does not store samples whose values are less than lowreject. The sorted CDF will still be properly normalized.

EmpiricalCDFs.countsMethod
counts(cdf::AbstractEmpiricalCDF)

Return the number of counts added to cdf. This includes counts that may have been discarded because they are below of the cutoff.

EmpiricalCDFs.dataMethod
data(cdf::AbstractEmpiricalCDF)

return the array holding samples for cdf.

EmpiricalCDFs.finvMethod
finv(cdf::AbstractEmpiricalCDF) --> Function

Return the quantile function, that is, the functional inverse of cdf. cdf is a callable object. Note that finv differs slightly from quantile.

Examples

Here, cdf contains $10^6$ samples from the unit normal distribution.

julia> icdf = finv(cdf);
julia> icdf(.5)
-0.00037235611091389375
julia> icdf(1.0-eps())
4.601393290425543
julia> maximum(cdf)
4.601393290425543
EmpiricalCDFs.linprintFunction
linprint(fn::String, cdf::AbstractEmpiricalCDF, n=2000)

print cdf to file fn. Print no more than n linearly spaced points.

EmpiricalCDFs.linprintFunction

linprint(io::IO ,cdf::AbstractEmpiricalCDF, n=2000) print (not more than) n linearly spaced points after sorting the data.

EmpiricalCDFs.logprintMethod

logprint(io::IO, cdf::EmpiricalCDF, n=2000) print (not more than) n log spaced points after sorting the data.

Base.append!Method
append!(cdf::EmpiricalCDF, a::AbstractArray)
append!(cdf_to::AbstractEmpiricalCDF, cdf_from::AbstractEmpiricalCDF)

Add samples in a to cdf. Add samples in cdf_from to cdf_to.

Base.printFunction
print(io::IO, cdf::AbstractEmpiricalCDF)

Call logprint(io,cdf)

Base.push!Method
push!(cdf::EmpiricalCDF,x::Real)

add the sample x to cdf.

Base.randMethod
rand(cdf::EmpiricalCDF)

Pick a random sample from the distribution represented by cdf.

Base.sort!Function
sort!(cdf::AbstractEmpiricalCDF)

Sort the data collected in cdf. You must call sort! before using cdf.