boltzkit.evaluation.density_based.ess
Functions
|
Compute the forward effective sample size (ESS) from log-importance weights. |
|
Compute the reverse effective sample size (ESS) from log-importance weights. |
- boltzkit.evaluation.density_based.ess.get_reverse_ess(log_weights: ndarray) float[source]
Compute the reverse effective sample size (ESS) from log-importance weights.
Reverse ESS measures how well a proposal distribution \(q(x)\) covers a target distribution \(p(x)\) in importance sampling.
Using weights \(w_i = \exp(\log p(x_i) - \log q(x_i))\), the ESS is:
\[\mathrm{ESS} = \frac{\left(\sum_i w_i\right)^2}{N \sum_i w_i^2}\]Log-form computation is used for numerical stability.
- Parameters:
log_weights (np.ndarray) –
Log importance weights:
\[\log w_i = \log p(x_i) - \log q(x_i)\]where \(x_i \sim q(x)\).
- Returns:
Reverse ESS in \((0, 1]\), representing the effective fraction of useful samples.
- Return type:
float
- boltzkit.evaluation.density_based.ess.get_forward_ess(log_weights: ndarray) float[source]
Compute the forward effective sample size (ESS) from log-importance weights.
Forward ESS measures overlap quality when samples are drawn from the target distribution \(p(x)\) and reweighted toward a proposal \(q(x)\).
It is defined as:
\[\mathrm{ESS} = \frac{1}{\mathbb{E}_p[w] \; \mathbb{E}_p[1/w]}\]where \(w = \exp(\log p(x) - \log q(x))\).
- Parameters:
log_weights (np.ndarray) –
Log importance weights:
\[\log w_i = \log p(x_i) - \log q(x_i)\]where \(x_i \sim p(x)\).
- Returns:
Forward ESS in \((0, 1]\), indicating how well the proposal distribution represents the target distribution.
- Return type:
float