mcframework.stats_engine.mean#

mcframework.stats_engine.mean(x: ndarray, ctx: StatsContext) float | None[source]#

Sample mean \(\bar X = \frac{1}{n}\sum_{i=1}^n x_i\).

Parameters:
xndarray

Input sample.

ctxStatsContext

If nan_policy="omit", non-finite values are excluded.

Returns:
float or None

Estimate of \(\mathbb{E}[X]\), or None if the cleaned sample is empty.

Notes

The averaging is performed on the filtered array returned by _clean(), so the effective sample size corresponds to the number of finite values that survive the configured NaN policy.

Examples

>>> mean(np.array([1, 2, 3]), StatsContext(n=3))
2.0