From 6a50b8d63ae1a8204eba20927ccfd730c7025903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Vran=C3=ADk?= Date: Tue, 14 Dec 2021 19:43:48 +0100 Subject: [PATCH] Quantile filter (#1715) Co-authored-by: pvranik Co-authored-by: Oxan van Leeuwen --- components/sensor/index.rst | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/components/sensor/index.rst b/components/sensor/index.rst index 595e3c54d..5bb8afd40 100644 --- a/components/sensor/index.rst +++ b/components/sensor/index.rst @@ -129,6 +129,11 @@ Filters are processed in the order they are defined in your configuration. window_size: 5 send_every: 5 send_first_at: 1 + - quantile: + window_size: 5 + send_every: 5 + send_first_at: 1 + quantile: .9 - sliding_window_moving_average: window_size: 15 send_every: 15 @@ -232,6 +237,41 @@ degree with a least squares solver. filters: - filter_out: 85.0 +``quantile`` +************ + +A `simple moving quantile `__ +over the last few values. This can be used to filter outliers from the received sensor data. A large +window size will make the filter slow to react to input changes. + +.. code-block:: yaml + + # Example configuration entry + - platform: wifi_signal + # ... + filters: + - quantile: + window_size: 7 + send_every: 4 + send_first_at: 3 + quantile: .9 + +Configuration variables: + +- **window_size** (*Optional*, int): The number of values over which to calculate the quantile + when pushing out a value. + Defaults to ``5``. +- **send_every** (*Optional*, int): How often a sensor value should be pushed out. For + example, in above configuration the quantile is calculated after every 4th + received sensor value, over the last 7 received values. + Defaults to ``5``. +- **send_first_at** (*Optional*, int): By default, the very first raw value on boot is immediately + published. With this parameter you can specify when the very first value is to be sent. + Must be smaller than or equal to ``send_every`` + Defaults to ``1``. +- **quantile** (*Optional*, float): value from 0 to 1 to determine which quantile to pick. + Defaults to ``.9``. + ``median`` **********