clenspy.selection.richness_kernel.emg_pdf

clenspy.selection.richness_kernel.emg_pdf(x, mu, sigma, tau)[source]

The EMG density, Costanzi et al. (2019a) Eq. 6.

\[p_{\rm EMG}(x) = \frac{\tau}{2} e^{\frac{\tau}{2}\left(2\mu + \tau\sigma^2 - 2x\right)} \operatorname{erfc}\!\left( \frac{\mu + \tau\sigma^2 - x}{\sqrt2\,\sigma}\right)\]

NOTE: same overflow problem as emg_cdf and the same cure. The exponential grows without bound while the erfc vanishes, so for \(t \ge 0\) this uses \(e^{a}\operatorname{erfc}(t) = \operatorname{erfcx}(t)\,e^{a - t^2}\), which is exact and keeps both factors bounded. The direct product is used only for \(t < 0\), where erfc is \(O(1)\) and erfcx would overflow instead.

NOTE: this is a density per unit richness, not a probability. Use emg_cdf for bin membership – the bin integral of this is analytic and there is no reason to quadrature it.

Parameters:
  • x (float or array-like) – Observed richness.

  • mu (float or array-like) – As for emg_cdf.

  • sigma (float or array-like) – As for emg_cdf.

  • tau (float or array-like) – As for emg_cdf.

Returns:

np.ndarray – The density, broadcast over the inputs.