Below is an example of the user page for a class. We document all pages in this uniform format.
* We use the active voice.
* Inline equations are between single dolar signs like this $\alpha$
* display equations between double dollars on separate lines and an empty line before and after the equation. like this

$$
y = x^2
$$

* The intro description at the top need to clearly describe what the function is doing. 
Don't use needless wording, be effective, all the information you write should be relevant and 
contain all the details, but don't burden readers with needless details or opinions to read things. On the 
other hand explain everything that is relevant to know for a user. People want quick acurate anwers 
in these documentation pages.
* Below the desciption we often have a single equation providing the computation details. Skip this is equations are too big or too long. 
I so then put the long details at the bottom of the page.
* Then we have a sections listing and explaining the constructor parameters.
* then we have a usage example with a plot. The plot format is also standarized and it requires working code.
* After a plot we have a section Formula Details that gives full equations and algorithmic desciptions about all the
details of the algorithm. It doesn't contain any python or c++ source code, only formulas and description.
The descriptions should contain all the relevant info so that someone could implement a replication of the functionality of the class.
------------
# `EwMean`

## Description

`EwMean` computes the exponentially weighted moving mean of a data sequence, applying more weight to recent data points and allowing for a smoother, lagged response. You specify the decay rate through `alpha`, calculated from `com`, `span`, `halflife`, or `alpha` itself, aligning with the Pandas `ewm` interface.

*Equation*:

$$
y[i] = \frac{ x[i] (1 - \alpha) + x_[i-1](1 - \alpha)^2 + x[i-2](1 - \alpha)^3 \cdots}{1 + (1 - \alpha) + (1 - \alpha)^2 + (1 - \alpha)^3 \cdots}
$$

### Parameters

One of the following decay parameters is required to calculate `alpha`, where a higher `alpha` value gives recent points more influence:

- **`com`**: Center of mass. `alpha = 1 / (1 + com)`
- **`span`**: Span. `alpha = 2 / (span + 1)`
- **`halflife`**: Half-life. `alpha = 1 - exp(-log(2) / halflife)`
- **`alpha`**: Directly specifies the smoothing factor, where `0 < alpha < 1`

*NaN handling*: NaN values are ignored in the mean calculation.

## Usage Example and Plot

```{eval-rst}
.. plotly::
    :include-source: True

    import numpy as np
    import plotly.graph_objects as go
    from plotly.subplots import make_subplots
    from screamer import EwMean

    # Generate example data
    data = np.cumsum(np.random.normal(size=300))

    # Compute exponentially weighted mean with a span of 20
    ewmean_data = EwMean(span=20)(data)

    # Create subplots with original and transformed data
    fig = make_subplots(rows=2, cols=1, shared_xaxes=True, row_heights=[1/2, 1/2], vertical_spacing=0.1)

    fig.add_trace(go.Scatter(y=data, mode='lines', name='Original Data'), row=1, col=1)
    fig.add_trace(go.Scatter(y=ewmean_data, mode='lines', name='EwMean', line=dict(color='red')), row=2, col=1)

    fig.update_layout(
        title="Exponentially Weighted Moving Mean",
        xaxis_title="Index",
        yaxis=dict(title="Original Data"),
        yaxis2=dict(title="EwMean"),
        margin=dict(l=20, r=20, t=80, b=20),
        legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1)        
    )

    fig.show()
```

### Formula Details

`EwMean` computes the exponentially weighted moving mean recursively. This calculation approach provides a fast, iterative update for each new value without recalculating the entire window, giving more weight to recent observations. The weighted mean formula aligns with the Pandas `ewm` interface by adjusting for the weighted contribution of each new element.


Let:
- **`alpha`** be the smoothing factor calculated from `com`, `span`, `halflife`, or specified directly, where `0 < alpha < 1`.

For each new data point $x_t$, `EwMean` updates two cumulative sums, $S_x$ and $S_w$, as follows:

1. Adjust $S_x$ by retaining a fraction $(1 - \alpha)$ of the previous weighted sum and then adding the new value $x_t$:
   
$$
S_x = S_x \times (1 - \alpha) + x_t
$$

1. Adjust $S_w$, the cumulative weight, by similarly retaining a fraction $(1 - \alpha)$ of the previous weight sum, then adding a weight of $1$:

$$
S_w = S_w \times (1 - \alpha) + 1
$$

3. Compute the exponentially weighted moving mean as:

$$
\text{EwMean} = \frac{S_x}{S_w}
$$
------------