diff --git a/src/univariate.jl b/src/univariate.jl index a82605cb..ae09eab6 100644 --- a/src/univariate.jl +++ b/src/univariate.jl @@ -66,8 +66,7 @@ function kde_range(boundary::Tuple{Real,Real}, npoints::Int) lo, hi = boundary lo < hi || error("boundary (a,b) must have a < b") - step = (hi - lo) / (npoints-1) - lo:step:hi + Compat.range(lo, stop=hi, length=npoints) end struct UniformWeights{N} end diff --git a/test/univariate.jl b/test/univariate.jl index dcefd08d..dd848950 100644 --- a/test/univariate.jl +++ b/test/univariate.jl @@ -13,6 +13,8 @@ end r = kde_range((-2.0,2.0), 128) @test step(r) > 0 +r2 = kde_range((0.12698109160784082, 0.9785547869337731), 256) +@test length(r2) == 256 for X in ([0.0], [0.0,0.0], [0.0,0.5], [-0.5:0.1:0.5;]) w = default_bandwidth(X)