38 if (sortedData.size() == 0)
40 throw LocalException(
"GetPercentile not possible for empty vector");
43 float indexf = (sortedData.size() - 1) * percentile;
45 int index = (int)indexf;
46 float f = indexf -
index;
48 if (
index == (
int)sortedData.size() - 1)
50 return sortedData.at(sortedData.size() - 1);
53 return sortedData.at(
index) * (1 - f) + sortedData.at(
index + 1) * f;
56 static std::vector<float>
59 std::vector<float> result;
60 result.push_back(sortedData.at(0));
62 for (
int i = 1; i < percentiles; i++)
64 result.push_back(
GetPercentile(sortedData, 1.f / percentiles * i));
67 result.push_back(sortedData.at(sortedData.size() - 1));