Posterior Density and Mode Metrics
When To Use
Use this skill after a PMD or proxy density run has produced particles, weights, grid densities, or explicit mode locations. Do not use it to generate observations or update particles.
Inputs
- Particle locations and normalized weights.
- Expected posterior mode coordinates and a radius for reduced mode checks.
- Optional grid target and estimated density arrays with a cell area.
Outputs
total_variationandcross_entropyfor grid densities when available.- Per-mode mass, mass ratio, effective sample size, and
mode_coverage_score. - Mechanism-check booleans suitable for recovery validation.
Workflow
- Confirm weights are nonnegative and normalized within numerical tolerance.
- Accumulate particle mass inside each expected mode ball.
- Convert balanced multimodal support into
mode_coverage_score. - For grid inputs, compute total variation and cross entropy with a shared cell area.
- Emit mechanism checks that distinguish metric success from actual PMD execution.
Validation
Run:
python tests/test_density_metrics.py
Limitations
The mode score is a reduced synthetic proxy for the paper's full figure-level total variation and cross-entropy comparisons. It should be interpreted only with the recorded PMD trace.