InterpolatedPDFs.jl

InterpolatedPDFs.fit_cpl โ€” Method
fit_cpl(x::AbstractArray, s::AbstractArray)

Fits a LinearInterpolatedPDF distribution to s using x for the breakpoints.

Examples

julia> x = range(0, stop=pi, length=5);

julia> s = acos.(rand(100));

julia> d = fit_cpl(x,s)
LinearInterpolatedPDF{Float64,1}(
pdf_itp: 5-element extrapolate(scale(interpolate(::Array{Float64,1}, BSpline(Linear())), (0.0:0.39269908169872414:1.5707963267948966,)), Throw()) with element type Float64:
 0.15242714502015237
 0.36726001464827923
 0.7290336549033926
 0.8405744820809898
 1.0667947306551753
cdf_itp: 5-element extrapolate(scale(interpolate(::Array{Float64,1}, BSpline(Linear())), (0.0:0.39269908169872414:1.5707963267948966,)), Throw()) with element type Float64:
 0.0
 0.10204033518620566
 0.31729709383873866
 0.6254889308490448
 1.0
invcdf_itp: 5-element extrapolate(interpolate((::Array{Float64,1},), ::Array{Float64,1}, Gridded(Linear())), Throw()) with element type Float64:
 0.0
 0.39269908169872414
 0.7853981633974483
 1.1780972450961724
 1.5707963267948966
)
source
InterpolatedPDFs.LinearInterpolatedPDF โ€” Type
LinearInterpolatedPDF{T,N,ITP,IT} <: ContinuousUnivariateDistribution

A continuous univariate linearly interpolated distribution. The pdf, cdf, and inverse cdf are interpolated. Using this construction directly requires the input to be normalized.

See also: fit_cpl

Examples

julia> x,y = [1.0, 2.0, 3.0], [0.75, 0.5, 0.25]
([1.0, 2.0, 3.0], [0.75, 0.5, 0.25])

julia> LinearInterpolatedPDF(x,y)
LinearInterpolatedPDF{Float64,1,Interpolations.GriddedInterpolation{Float64,1,Float64,Interpolations.Gridded{Interpolations.Linear},Tuple{Array{Float64,1}}},Interpolations.Gridded{Interpolations.Linear}}(
pdf_itp: 3-element extrapolate(interpolate((::Array{Float64,1},), ::Array{Float64,1}, Gridded(Interpolations.Linear())), Throw()) with element type Float64:
 0.75
 0.5
 0.25
cdf_itp: 3-element extrapolate(interpolate((::Array{Float64,1},), ::Array{Float64,1}, Gridded(Interpolations.Linear())), Throw()) with element type Float64:
 0.0
 0.625
 1.0
invcdf_itp: 3-element extrapolate(interpolate((::Array{Float64,1},), ::Array{Float64,1}, Gridded(Interpolations.Linear())), Throw()) with element type Float64:
 1.0
 2.0
 3.0
)

julia> pdf(d,1.5)
0.625

julia> cdf(d,2.5)
0.8125

julia> quantile(d,0.5)
1.8
source

Index