35 static float GetPercentile(
const std::vector<float>& sortedData,
float percentile)
37 if (sortedData.size() == 0)
39 throw LocalException(
"GetPercentile not possible for empty vector");
42 float indexf = (sortedData.size() - 1) * percentile;
44 int index = (int)indexf;
45 float f = indexf -
index;
47 if (
index == (
int)sortedData.size() - 1)
49 return sortedData.at(sortedData.size() - 1);
52 return sortedData.at(
index) * (1 - f) + sortedData.at(
index + 1) * f;
54 static std::vector<float>
GetPercentiles(
const std::vector<float>& sortedData,
int percentiles)
56 std::vector<float> result;
57 result.push_back(sortedData.at(0));
59 for (
int i = 1; i < percentiles; i++)
61 result.push_back(
GetPercentile(sortedData, 1.f / percentiles * i));
64 result.push_back(sortedData.at(sortedData.size() - 1));
67 static float GetMedian(
const std::vector<float>& sortedData)