From 56d59b17601cd6118fc79be3788ebc0771967466 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sun, 16 Jun 2019 19:14:09 +0200 Subject: [PATCH] bugfixed auto-ranged KDE to include the minimum and maximum value in the output --- lib/jkqtcommon/jkqtpstatkde.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/jkqtcommon/jkqtpstatkde.h b/lib/jkqtcommon/jkqtpstatkde.h index f4cda73114..fbffdb7513 100644 --- a/lib/jkqtcommon/jkqtpstatkde.h +++ b/lib/jkqtcommon/jkqtpstatkde.h @@ -239,11 +239,15 @@ inline void jkqtpstatKDE1DAutoranged(InputIt first, InputIt last, OutputIt KDEXO const double binw=range/static_cast(Nout); // calculate the KDE - for (int i=0; i(i)*binw+binw/2.0; - histX.push_back(x); - histY.push_back(jkqtpstatEvaluateKernelSum(x, first, last, kernel, bandwidth)); + for (double xi=minV; xi<=maxV; xi+=binw) { + histX.push_back(xi); + histY.push_back(jkqtpstatEvaluateKernelSum(xi, first, last, kernel, bandwidth)); } + if (histX.size()>0 && histX[histX.size()-1] histX; std::vector histY; - const double range=maxV-minV; const double binw=binWidth; - const int Nout=static_cast(ceil(range/binWidth)); // calculate the KDE - for (int i=0; i(i)*binw+binw/2.0; + for (double xi=minV; xi<=maxV; xi+=binw) { histX.push_back(xi); histY.push_back(jkqtpstatEvaluateKernelSum(xi, first, last, kernel, bandwidth)); } + if (histX.size()>0 && histX[histX.size()-1]