demo_package
Demo package used to showcase the mkdocs-eds extensions.
MovingAverage
[source]
Compute a moving average over the most recent values.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
window |
Number of samples used to compute the average. Must be positive.
TYPE:
|
update
[source]
Add a value to the window and return the current average.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
value |
New data point.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The average of the recorded values. |
as_dict
[source]
Serialize the current state.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, float]
|
Dictionary with the window size and the number of values seen. |
add
[source]
Add two numbers.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
a |
First value.
TYPE:
|
b |
Second value.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The sum of both numbers. |
Examples
add(1, 2)
scale_values
[source]
Scale every value by a factor.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
values |
Iterable of numbers to scale.
TYPE:
|
factor |
Multiplier applied to each value.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[float]
|
Scaled values as a list. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the factor is zero. |