From a2ff1649d3606cd33f0354a976d72c3eb6105760 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 6 Jan 2021 10:20:57 -0500 Subject: [PATCH] Give UnivariateKDE distribution-like overloads Upstreams https://github.com/SciML/DiffEqUncertainty.jl/pull/41 . Allows for it to be "distribution-like". Still missing the random sampling. --- src/univariate.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/univariate.jl b/src/univariate.jl index 825626fb..92a17faf 100644 --- a/src/univariate.jl +++ b/src/univariate.jl @@ -20,6 +20,10 @@ mutable struct UnivariateKDE{R<:AbstractRange} <: AbstractKDE density::Vector{Float64} end +Base.eltype(K::UnivariateKDE) = eltype(K.density) +Base.minimum(K::UnivariateKDE) = minimum(K.x) +Base.maximum(K::UnivariateKDE) = maximum(K.x) + # construct kernel from bandwidth kernel_dist(::Type{Normal},w::Real) = Normal(0.0,w) kernel_dist(::Type{Uniform},w::Real) = (s = 1.7320508075688772*w; Uniform(-s,s))