Statistics & probability

Optimal finite differential privacy mechanism calculator from a loss matrix

Optimize a finite pure-DP stochastic channel for supplied prior, loss and adjacency, with explicit numerical rounding.

Your numbers

Valid JSON. Pure DP adjacent input pairs. Exponential privacy bound conservatively rounded before exact-rational LP.
Valid JSON; preserve the shown array or object structure.
Valid JSON; preserve the shown array or object structure.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A finite privacy mechanism is a table of output probabilities for each possible private input. The optimization chooses that table to minimize a supplied expected loss while respecting the specified privacy constraints.

THE FORMULAFinitepurelocalDPchannelQ_{xy} forinputx andoutputy. Supplyinputpriorπ,lossL,adjacencyrelation,ε≥0. LPminΣπ_xL_xyQ_xy s.t.eachinputrowΣ_yQ_xy=1,Q≥0, Q_xy≤e^εQ_xprime_y for eachordered adjacentinputpair/output. ForlocalDPallinputpairs adjacent bydefault. UseboundedLPsolverwithprimal feasibility,dualfeasibilityandobjectivegapcertificate;notgradientheuristicclaimglobal. ε0 connectedgraph implies identicalrows. Reportexpectedloss notprivacyguaranteebeyondprovided adjacency or repeatedusecomposition.

A worked example

With the prefilled inputs, expectedLoss = 0.2500000625000156. Pure DP adjacent input pairs. Exponential privacy bound conservatively rounded before exact-rational LP.

Good to know

Pure DP for supplied symmetric adjacency only. exp(epsilon) is rounded conservatively downward before exact-rational simplex; optimum is for that slightly stricter rounded bound, not an exact transcendental-coefficient optimum.

Choose a release mechanism

A finite privacy mechanism is a table of output probabilities for each possible private input. The optimization chooses that table to minimize a supplied expected loss while respecting the specified privacy constraints.

The loss matrix expresses what kinds of output mistakes matter. A mechanism optimized for one input prior and loss function is not automatically optimal for another application or population.

Optimal binary randomized-response referenceBinary pure-private channel at ε = log 3released 0released 1input 00.750.25input 10.250.75Row sums = 1; max probability ratio = 3Equal input prior + 0/1 loss: expected loss = 0.25
Scroll across to see the full diagram.
At epsilon=log3, a symmetric channel with correct-output probability3/4 and error probability1/4 satisfies all-pairs purelocalDP and minimizes equal-prior zero-one loss. This is a reference, not proof anLPengine is complete.

Compare with the Analytic Gaussian mechanism noise calibration calculator. Design a finite randomized channel minimizing expected loss under likelihood-ratio privacy constraints; Gaussian calibration selects noise scale for a fixed mechanism.

Define neighboring inputs

Pure DP adjacent input pairs. Exponential privacy bound conservatively rounded before exact-rational LP.Pure epsilon differential privacy bounds how much an output probability can change between neighboring inputs. In the local all-pairs convention, every pair of possible input values is protected.

A custom adjacency graph defines a different guarantee. Reporting only epsilon without the neighboring-input definition leaves out a central part of the privacy claim. The decision variables are one output-probability row for each input. Every row sums to one, and nonnegativity ensures that the result is a stochastic channel. The prior weights the loss for each true input and output pair. Adjacency is supplied as input pairs and is enforced in both directions. An omitted adjacency relation is not silently inferred from a complete graph or from numerical closeness of input labels. Differential privacy therefore applies to the declared neighborhood model, which must match the intended disclosure problem before an optimized loss has practical meaning.

Supply probabilities and losses

The input prior contains nonnegative probabilities that sum to one. The loss matrix has one row per input and one column per possible released output.

Each mechanism row must also sum to one. Its entries are probabilities, not deterministic recommendations or frequencies from an already released dataset; they describe how a later randomized release would behave.

Solve the constrained linear program

The expected loss is linear in the channel entries, and the pure-privacy inequalities are linear once epsilon is fixed. This finite formulation can therefore be solved with a linear-programming method.

A usable result needs feasibility checks and an optimization certificate or verified objective gap. A visually plausible probability table is insufficient if even one neighboring-pair inequality is violated.

Binary randomized-response example

Take two equally likely inputs, zero loss for a correct output and unit loss for an incorrect output. At epsilon equal to log three, an optimal symmetric channel returns the correct value with probability three-quarters.

The opposite output has probability one-quarter, and expected loss is one-quarter. The largest probability ratio between the two input rows is three, matching the stated exp-epsilon bound.

Understand the zero-privacy-budget limit

At epsilon zero, adjacent input rows must be identical. If the adjacency graph is connected, the released output distribution cannot depend on which input value was supplied.

The best input-independent output can be nonunique. In the equal-prior binary example, every identical-row channel has expected zero-one loss one-half, so a single returned optimizer should not be described as uniquely optimal.

Keep the guarantee within scope

The solved table protects only the declared input relation and one mechanism invocation. Repeated releases need a composition analysis, and other information paths can invalidate the intended system-level protection.

This calculator designs a finite probabilistic channel; it does not certify a legal anonymization standard or an entire data pipeline. Retain the prior, adjacency, loss and feasibility diagnostics with the mechanism. The exponential privacy ratio is rounded conservatively downward before the exact-rational simplex calculation. Objective coefficients are also rounded to six decimal places. The returned channel is certified for that rounded linear program, and the expected loss is reevaluated with the original supplied costs. An objective-rounding bound accompanies the result. This distinction matters when costs are very small or two channels are nearly tied. At most thirty-two probability variables and eighty transformed constraints are supported; reducing alphabet size may be necessary. There is no approximate-delta privacy parameter, interactive composition theorem or claim that the chosen loss captures every possible consequence of disclosure. Pure DP for supplied symmetric adjacency only. exp(epsilon) is rounded conservatively downward before exact-rational simplex; optimum is for that slightly stricter rounded bound, not an exact transcendental-coefficient optimum.

A few questions, answered

Does a smaller epsilon usually protect inputs more strongly?

For the same adjacency and mechanism setting, smaller epsilon imposes tighter probability-ratio constraints, often at a utility cost.

What does epsilon zero require?

Adjacent inputs must have identical output distributions; connected adjacency makes every input row identical.

Can I use delta-positive approximate privacy here?

Not with only these pure-privacy constraints; that requires a separately specified formulation.

Is the optimized channel itself a released dataset?

No. It is a probability rule that a later randomized release would follow.

Find your calculator

Start typing to explore the library.