From 1831dad8e40548f4403217c2a747443f0a9c931c Mon Sep 17 00:00:00 2001
From: Rainer Kartmann <rainer.kartmann@student.kit.edu>
Date: Thu, 14 Mar 2019 16:59:23 +0100
Subject: [PATCH] Fixed quantile for p = 1

---
 VirtualRobot/math/statistics/measures.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/VirtualRobot/math/statistics/measures.cpp b/VirtualRobot/math/statistics/measures.cpp
index a69494c82..2597ad0e6 100644
--- a/VirtualRobot/math/statistics/measures.cpp
+++ b/VirtualRobot/math/statistics/measures.cpp
@@ -73,7 +73,7 @@ float quantile(const std::vector<float>& _values, float p, bool isSorted)
     checkNotEmpty(_values);
     const std::vector<float>& values = isSorted ? _values : sorted(_values);
     
-    float location = p * values.size();
+    float location = p < 1 ? p * values.size() : values.size() - 1;
     
     std::size_t floor = static_cast<std::size_t>(std::floor(location));
     std::size_t ceil = static_cast<std::size_t>(std::ceil(location));
-- 
GitLab