<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# Differential Privacy — API Reference

## Laplace Mechanism

```bash
node scripts/agent.js --action laplace \
  --true-value 1523 --sensitivity 1 --epsilon 1.0
```

## Gaussian Mechanism

```bash
node scripts/agent.js --action gaussian \
  --true-value 45.7 --sensitivity 1.0 --epsilon 1.0 --delta 1e-5
```

## Privacy Budget Tracking

```bash
node scripts/agent.js --action budget \
  --total-epsilon 5.0 \
  --queries '[{"name":"count","epsilon":1.0},{"name":"mean","epsilon":2.0}]'
```

## DP Histogram

```bash
node scripts/agent.js --action histogram --values "10,25,30,15,20" --epsilon 1.0
```

## Sensitivity Calculation

```bash
node scripts/agent.js --action sensitivity --query-type "count"
node scripts/agent.js --action sensitivity --query-type "sum" --bounds "0,100"
```

## Epsilon Guidelines

| ε Value | Privacy Level | Use Case |
|---------|--------------|----------|
| 0.01–0.1 | Very strong | Census, healthcare |
| 0.1–1.0 | Strong | Sensitive analytics |
| 1.0–5.0 | Moderate | General analytics |
| 5.0–10.0 | Weak | Low-sensitivity data |

## Mechanism Selection

| Query Type | Mechanism | Sensitivity |
|------------|-----------|-------------|
| Count | Laplace | Δf = 1 |
| Sum (bounded) | Laplace | Δf = upper - lower |
| Mean (bounded) | Gaussian | Δf ≈ range / n |
| Histogram | Laplace | Δf = 1 per bin |
| Selection | Exponential | Δu = utility range |

## Composition Rules

| Type | Formula |
|------|---------|
| Sequential | ε_total = Σ εᵢ |
| Parallel (disjoint) | ε_total = max(εᵢ) |
| Advanced (Rényi) | Tighter bounds via moments accountant |
