20 Commits

Author SHA1 Message Date
Chris Wilson
8506cdcaa5 lib: Allow storing floating point values in igt_stats
We don't always have precise integers with which to store, so allow
degrading to double precision floating point based on available input.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-07-19 15:30:23 +01:00
Damien Lespiau
643aab2249 stats: Add wikipedia links to get_trimean() and get_iqm()
Useful knowledge for anyone looking at the documentation and following
the linkes.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-07-02 11:20:42 +01:00
Chris Wilson
2d305f6199 stats: Add trimean
https://en.wikipedia.org/wiki/Trimean

	The trimean is a the most efficient 3-point L-estimator (estimator
	of central tendency, i.e. average), even more robust than the
	median at estimating the average of a sample population.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-07-01 18:58:46 +01:00
Chris Wilson
19135a3447 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>
2015-07-01 18:58:46 +01:00
Damien Lespiau
66e0bf66da stats: Spwan igt_init_with_size() from igt_init()
It's all about good looking APIs.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 19:05:41 +01:00
Damien Lespiau
00432ff260 stats: Allow the underlying arrays to grow at will
Chris mentioned he wanted to be able to measure a variable "for one
second" and use igt_stats to store them. That's one case where we don't
know the number of data points upfront.

We should really support that, so here it is.

v2: Just free ->sorted when a new capacity is needed.
    ensure_sorted_values() will then reallocate the array to the new
    capacity on demand (Chris)

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 19:05:41 +01:00
Damien Lespiau
fabde384a3 stats: Add support for the interquartile range (IQR)
IQR is a good measure of dispersion.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:08 +01:00
Damien Lespiau
1b8997b3f8 stats: Add support for quartiles (and thus median)
More stuff, quite useful characteristics of a dataset.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:08 +01:00
Damien Lespiau
3839bacde8 stats: Add a bulk version of _push()
In case we want to push a bunch of values in one go.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:08 +01:00
Damien Lespiau
0e4c175e04 stats: Add igt_stats_get_range()
Somewhat useful, for instance to size an histogram.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
4a89a841a1 stats: Add functions to retrieve min/max values of the dataset
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
17ed69fbb8 stats: Add a note about the standard deviation derived from unbiased variance
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
da123adeae stats: Add a getter for the population property
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
3a5cf84317 stats: Add a way to specify if the data set is a population or a sample
This changes how we compute the variance. We want an unbiased variance
when reasoning about a sample.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
a2f6fd3725 stats: Add gtkdoc section for igt_stats
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
203c3841fc stats: Zero the whole structure at init() time
Because the structure started small, I initialized every member
directly, but that means that the new fields added weren't properly
initialized (sigh!). Zero the whole thing first then.

Also, the punishment for introducing a bug should be to write the
corresponding unit test. It's not a perfect one, but I'll take it.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
515cec1210 stats: Add a way to retrieve the standard deviation
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:03:27 +01:00
Damien Lespiau
05c10f940f stats: Use an algorithm popularised by Knuth to compute mean and variance
Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:03:27 +01:00
Damien Lespiau
e55a11d3eb stats: Be more precise and talk about mean, not average
There are several types of averages eg. mean, median and mode.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:03:27 +01:00
Damien Lespiau
06f5f7065f lib: Add a tiny utility function to compute averages
The master plan would be to get a bit more stats in it, at least the
standard deviation and confidence interval. Just need the average for
now.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-25 17:22:03 +01:00