From 73cf9cf86d561651d77e42a5d58e9b513a9968ac Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 23 May 2018 11:24:23 +0800 Subject: [PATCH 1/2] =wrap around below --- src/univariate.jl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/univariate.jl b/src/univariate.jl index a82605cb..6d93e22c 100644 --- a/src/univariate.jl +++ b/src/univariate.jl @@ -93,10 +93,19 @@ function tabulate(data::RealVector, midpoints::Range, weights::Weights=default_w for (i,x) in enumerate(data) k = searchsortedfirst(midpoints,x) j = k-1 - if 1 <= j <= npoints-1 - grid[j] += (midpoints[k]-x)*ainc*weights[i] - grid[k] += (x-midpoints[j])*ainc*weights[i] + @assert j <= npoints -1 + mid_above = midpoints[k] + + if j >= 1 + mid_below = midpoints[j] + if + @assert j==0 + mid_below = midpoints[1] - s # Imaginary point outside boundry + j=npoints # Wrap around and allocate this to the top end + grid[j] += (mid_above-x)*ainc*weights[i] + grid[k] += (x-mid_below)*ainc*weights[i] + end # returns an un-convolved KDE From 7b737016e1f7250f12de9e3a87567a61ae27317c Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 23 May 2018 11:57:53 +0800 Subject: [PATCH 2/2] =wrap around below --- src/univariate.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/univariate.jl b/src/univariate.jl index 6d93e22c..b37a8a4b 100644 --- a/src/univariate.jl +++ b/src/univariate.jl @@ -98,7 +98,7 @@ function tabulate(data::RealVector, midpoints::Range, weights::Weights=default_w if j >= 1 mid_below = midpoints[j] - if + else @assert j==0 mid_below = midpoints[1] - s # Imaginary point outside boundry j=npoints # Wrap around and allocate this to the top