Skip to content
Back to skills

Apt Posterior Transformation

ASecurity

Compute APT posterior-to-proposal-posterior transformations for Gaussian and finite normalized density settings without importance weighting.

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 9, 2026
businesspythonbash

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill apt_posterior_transformation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Apt Posterior Transformation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Apt Posterior Transformation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-apt-posterior-transformation/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-apt-posterior-transformation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: apt_posterior_transformation
description: Compute APT posterior-to-proposal-posterior transformations for Gaussian and finite normalized density settings without importance weighting.
---

# APT Posterior Transformation

Use this skill when a recovery or implementation needs the central APT transformation from a true-posterior estimator `q(theta | x)` to the proposal-posterior density used for proposal-drawn training data. Do not use it for SNPE-B-style importance weighting or SNPE-A-style post-hoc posterior correction.

## Inputs

- Posterior estimate density values or Gaussian parameters.
- Prior density values or Gaussian parameters.
- Proposal density values or Gaussian parameters.
- Optional finite grid or atom scores for normalization checks.

## Outputs

- Gaussian transformed proposal-posterior mean and variance.
- Finite normalized probabilities proportional to `q(theta | x) * proposal(theta) / prior(theta)`.
- Diagnostics for invalid transformed precision, nonfinite scores, or support mismatches.

## Workflow

1. For generic finite points, compute `log_q + log_proposal - log_prior`.
2. Normalize with log-sum-exp to get proposal-posterior probabilities.
3. For Gaussian inputs, compute transformed precision:
   `posterior_precision + proposal_precision - prior_precision`.
4. Compute transformed mean from the transformed natural mean.
5. Reject or flag invalid transforms where precision is not positive.

## Validation

Run:

```bash
python tests/test_transformation.py
```

The tests compare Gaussian closed form against finite-grid normalization and check numerical stability.
They also assert that invalid Gaussian precision is reported rather than converted into a nonsensical variance.

## Limitations

- The script implements scalar Gaussian transforms and finite-score normalization.
- Mixture-of-Gaussians formulas are described in the paper but not fully implemented here because the reduced recovery only needs scalar Gaussian checks.
- This skill provides transformation math; it does not run simulator rounds or optimizer steps.

Files in this skill

  • SKILL.md2 KB
  • scripts/apt_transform.py3.6 KB
  • tests/test_transformation.py1.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…