pypomp.maths.logmeanexp¶
- pypomp.maths.logmeanexp(x: Any, axis: None = None, ignore_nan: bool = False) float[source]¶
- pypomp.maths.logmeanexp(x: Any, axis: int | tuple[int, ...], ignore_nan: bool = False) ndarray
Compute the log of the mean likelihood from log-likelihood values.
Calculates
log(mean(exp(x)))in a numerically stable way using the log-sum-exp trick. This is appropriate when the estimator is unbiased on the natural (probability) scale, e.g. for averaging particle filter log-likelihood estimates across replicates.- Parameters:
x (array-like) – Collection of log-likelihood values.
axis (int, tuple of int, or None, optional) – Axis or axes along which to compute the mean. If
None(default), compute over the entire array.ignore_nan (bool, optional) – If
True, treat NaN entries as-inf(i.e. zero probability) before computing. Defaults toFalse.
- Returns:
The log-mean-exp value. A scalar
floatwhenaxis=None, otherwise anumpy.ndarraywith the reduced dimension removed.- Return type:
float or np.ndarray
See also
logmeanexp_seJackknife standard error for this estimator.