Skip to content
Back to skills

Ess Policy Distance

ASecurity

Compute P3O effective sample size and derive adaptive clipping and KL coefficients from replay policy probabilities.

  • 247 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 9, 2026
testingpythondocumentation

Works with

  • cli

Security analysis

A100/100

Scanned September 9, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Ess Policy Distance?

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

Security grade badge for Ess Policy Distance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-ess-policy-distance/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-ess-policy-distance)

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

SKILL.md
---
name: ess_policy_distance
description: Compute P3O effective sample size and derive adaptive clipping and KL coefficients from replay policy probabilities.
---

# ESS Policy Distance

Use this skill when implementing or auditing P3O replay updates that need the paper's automatic hyperparameter schedule. Do not use it for unrelated off-policy methods that tune clipping or regularization manually.

## Inputs
- `target_probs`: probabilities assigned by the current target policy to sampled actions.
- `behavior_probs`: probabilities stored with replay data by the behavior policy.

## Outputs
- `importance_ratios`: target divided by behavior probabilities.
- `ess`: normalized effective sample size in `[0, 1]`.
- `clip_threshold`: equal to `ess`.
- `kl_coefficient`: equal to `1 - ess`.

## Workflow
1. Validate non-empty equal-length probability vectors.
2. Clamp denominators by a small epsilon to avoid division by zero.
3. Compute ratios `rho = pi_theta(a|s) / beta(a|s)`.
4. Compute normalized ESS as `(sum(rho)^2) / (N * sum(rho^2))`.
5. Return `c = ESS` and `lambda = 1 - ESS` for the P3O update.

## Source Boundary
Use this skill with the paper, module documents, generated artifacts, and ordinary package documentation. Do not read or depend on the original P3O repository.

## Validation
Run `python scripts/<script>.py --self-test` or `python -m pytest tests` from the skill directory. The bundled tests use only the Python standard library.

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…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.