Commit 4e5e989
committed
Fix exponential_moving_average for window_size=1
The warmup branch used `i <= window_size`, so with window_size=1 the
second price was averaged ((10+20)*0.5=15) instead of applying the
documented smoothing factor alpha=2/(1+1)=1, which must return each
input unchanged. Narrowing the warmup to `i < window_size` applies
the exponential recurrence from the second value onward, and adds a
doctest pinning the window_size=1 behavior.1 parent 7f81fcd commit 4e5e989
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | | - | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
0 commit comments