Continuous averaging of solar cell efficiency

42 Views Asked by At

I have a stream of numbers - efficiency ratio of solar cells - in range 0-100%. The efficiency is defined as (produced/expected)*100.

I'm measuring the ratio every minute, and I'd like to have a "cumulative" ratio that shows the average.

A little problem is at night, when the ratio becomes undefined, since there is no light and no power. I'm setting it to zero at night, and this would be excluded from the computation of average.

Is there some formula how to keep such average, so that it'll show ever-improving average of the efficiency? I want that when the solar cells age, and lose efficiency, that this average would also lower - but when for example snow falls onto the cells, and they don't work properly, it should not ruin the average immediately.

Ideally I'd want to keep just one variable, maybe two. I can no way keep all the past values.

1

There are 1 best solutions below

0
On

I'll ignore the night for now. Your programs should be able to sort out all invalid data points and only report the good ones to our function. Let $a_1, ..., a_n$ be the sequence of old data points and $a_{n+1}$ the new one. We use $m_k$ do describe the (arithmetic) mean of the first $k$ values.

$$m_{n+1} = \frac{1}{n+1}\sum_{i=1}^{n+1} a_i = \frac{n}{n+1} \left(\frac{1}{n} \sum_{i=1}^{n} a_i\right) + \frac{a_{n+1}}{n+1} = \frac{n \cdot m_n}{n+1} + \frac{a_{n+1}}{n+1} $$

This formula $m_{n+1} = \frac{n\cdot m_n + a_{n+1}}{n+1}$ is rather easy to implement, but be aware that is is also likely to accumulate errors! The easies way to get around that, is a fresh recalculation of your current $m_{\text{today}}$ once a day at your favorite hour. Make sure to use a well written math library (in your language of choice) to ensure high accuracy & performance.