mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 17:36:11 +00:00
stats: Add the interquartile mean (IQM)
https://en.wikipedia.org/wiki/Interquartile_mean The IQM is a truncated mean and so is very similar to the scoring method used in sports that are evaluated by a panel of judges: discard the lowest and the highest scores; calculate the mean value of the remaining scores. It's useful to hide outliers in measurements (due to cold cache etc), without having to worry too much about the actual distribution. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
669b5da2bc
commit
19135a3447
@ -491,3 +491,40 @@ double igt_stats_get_std_deviation(igt_stats_t *stats)
|
||||
|
||||
return sqrt(stats->variance);
|
||||
}
|
||||
|
||||
/**
|
||||
* igt_stats_get_iqm:
|
||||
* @stats: An #igt_stats_t instance
|
||||
*
|
||||
* Retrieves the interquartile mean of the @stats dataset.
|
||||
*
|
||||
* The interquartile mean is a "statistical measure of central tendency".
|
||||
* It is a truncated mean that discards the lowest and highest 25% of values,
|
||||
* and calculates the mean value of the remaining central values.
|
||||
*/
|
||||
double igt_stats_get_iqm(igt_stats_t *stats)
|
||||
{
|
||||
unsigned int q1, q3, i;
|
||||
double mean;
|
||||
|
||||
igt_stats_ensure_sorted_values(stats);
|
||||
|
||||
q1 = (stats->n_values + 3) / 4;
|
||||
q3 = 3 * stats->n_values / 4;
|
||||
|
||||
mean = 0;
|
||||
for (i = 0; i <= q3 - q1; i++)
|
||||
mean += (stats->sorted[q1 + i] - mean) / (i + 1);
|
||||
|
||||
if (stats->n_values % 4) {
|
||||
double rem = .5 * (stats->n_values % 4) / 4;
|
||||
|
||||
q1 = (stats->n_values) / 4;
|
||||
q3 = (3 * stats->n_values + 3) / 4;
|
||||
|
||||
mean += rem * (stats->sorted[q1] - mean) / i++;
|
||||
mean += rem * (stats->sorted[q3] - mean) / i++;
|
||||
}
|
||||
|
||||
return mean;
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ uint64_t igt_stats_get_range(igt_stats_t *stats);
|
||||
void igt_stats_get_quartiles(igt_stats_t *stats,
|
||||
double *q1, double *q2, double *q3);
|
||||
double igt_stats_get_iqr(igt_stats_t *stats);
|
||||
double igt_stats_get_iqm(igt_stats_t *stats);
|
||||
double igt_stats_get_mean(igt_stats_t *stats);
|
||||
double igt_stats_get_median(igt_stats_t *stats);
|
||||
double igt_stats_get_variance(igt_stats_t *stats);
|
||||
|
Loading…
x
Reference in New Issue
Block a user