Z-score (standardised deviation from mean) sensor

I’m looking for a way to standardise various (mostly air quality related) sensors by calculating their z-score (see Wikipedia: Standard score). The z-score makes data comparable and easily interpretable.

The statistics sensor currently offers a standard_deviation state characteristic, and also one for mean. The formula for the z-score is:

(current_value - mean) / standard_deviation

For example a value of 1 can be interpreted as: the current value is one standard deviation above the (e.g. 24 hours) mean. These z-score sensors could easily be used for e.g. notifications, whenever a value is >2 or <-2 something “relevant” has happened recently.

What is the most efficient way to create a few dozen z-score sensors in HA without having a ton of other sensors in between that are only used for a single calculation? I’d prefer not having to create:

  1. statistics mean sensor
  2. statistics standard_deviation sensor
  3. template sensor: (current-mean)/standard_deviation

…because #1 and #2 would pollute the UI and would need to be excluded from the long term statistics. That’s okay for one or two sensors, but I’d like to normalise many sensors for many rooms, so I’m looking for a clean solution.

Thanks!