{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Additive Noise Mechanisms\n", "\n", "This notebook documents the variations on additive noise mechanisms in OpenDP:\n", "\n", "* Distribution: Laplace vs. Gaussian\n", "* Support: float vs. integer\n", "* Domain: scalar vs. vector\n", "* Bit-depth" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "----\n", "Any constructors that have not completed the proof-writing and vetting process may still be accessed if you opt-in to \"contrib\".\n", "Please contact us if you are interested in proof-writing. Thank you!" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "from opendp.mod import enable_features\n", "enable_features(\"contrib\")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Distribution: Laplace vs. Gaussian\n", "\n", "The Laplace mechanism is a ubiquitous algorithm in the DP community that is used to privatize an aggregate, like a sum or mean.\n", "\n", "An instance of the Laplace mechanism is captured by a _measurement_ containing the following six elements:\n", "\n", "
\n", " Elements of a Laplace Measurement\n", "\n", "1. We first define the **function** $f(\\cdot)$, that applies the Laplace mechanism to some argument $x$. This function simply samples from the Laplace distribution centered at $x$, with a fixed noise scale.\n", "\n", "$$f(x) = Laplace(\\mu=x, b=scale)$$\n", "\n", "2. Importantly, $f(\\cdot)$ is only well-defined for any finite float input. This set of permitted inputs is described by the **input domain** (denoted `AllDomain`).\n", "\n", "3. The set of possible outputs is described by the **output domain** (also `AllDomain`).\n", "\n", "4. The Laplace mechanism has a privacy guarantee in terms of epsilon. \n", "This guarantee is represented by a **privacy map**, a function that computes the privacy loss $\\epsilon$ for any choice of sensitivity $\\Delta$.\n", "\n", "$$map(\\Delta) = \\Delta / scale <= \\epsilon$$\n", "\n", "5. This map only holds if the same aggregation applied to any two neighboring datasets may differ by no more than some quantity $\\Delta$ under the absolute distance **input metric** (`AbsoluteDistance`).\n", "\n", "6. We similarly describe units on the output ($\\epsilon$) via the **output measure** (`MaxDivergence`).\n", "
\n", "\n", "\n", "The `make_base_laplace` constructor function returns the equivalent of the Laplace measurement described above." ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "noisy aggregate: -3.1135951257672723\n", "epsilon: 0.5\n" ] } ], "source": [ "from opendp.measurements import make_base_laplace\n", "\n", "# call the constructor to produce the measurement `base_lap`\n", "base_lap = make_base_laplace(scale=2.)\n", "\n", "# invoke the measurement on some aggregate x, to sample Laplace(x, 1.) noise\n", "aggregated = 0.\n", "print(\"noisy aggregate:\", base_lap(aggregated))\n", "\n", "# we must know the sensitivity of `aggregated` to determine epsilon\n", "absolute_distance = 1.\n", "print(\"epsilon:\", base_lap.map(d_in=absolute_distance))" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The analogous constructor for gaussian noise is `make_base_gaussian`: " ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "noisy aggregate: -2.713640944017099\n", "rho: 0.125\n" ] } ], "source": [ "from opendp.measurements import make_base_gaussian\n", "\n", "# call the constructor to produce the measurement `base_gauss`\n", "base_gauss = make_base_gaussian(scale=2.)\n", "\n", "# invoke the measurement on some aggregate x, to sample Gaussian(x, 1.) noise\n", "aggregated = 0.\n", "print(\"noisy aggregate:\", base_gauss(aggregated))\n", "\n", "# we must know the sensitivity of `aggregated` to determine epsilon\n", "absolute_distance = 1.\n", "print(\"rho:\", base_gauss.map(d_in=absolute_distance))" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Notice that `base_lap` measures privacy with epsilon, and `base_gauss` measures privacy with rho.\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Support: Float vs. Integer\n", "\n", "There are also discrete analogues of the continuous Laplace and Gaussian measurements.\n", "The continuous measurements accept and emit floats, while the discrete measurements accept and emit integers.\n", "Measurements with distributions supported on the integers expect integer sensitivities by default.\n", "\n", "`make_base_discrete_laplace` is equivalent to the geometric mechanism:" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "noisy aggregate: 0\n", "epsilon: 1.0\n" ] } ], "source": [ "from opendp.measurements import make_base_discrete_laplace\n", "\n", "# call the constructor to produce the measurement `base_discrete_lap`\n", "base_discrete_lap = make_base_discrete_laplace(scale=1.)\n", "\n", "# invoke the measurement on some integer aggregate x, to sample DiscreteLaplace(x, 1.) noise\n", "aggregated = 0\n", "print(\"noisy aggregate:\", base_discrete_lap(aggregated))\n", "\n", "# in this case, the sensitivity is integral:\n", "absolute_distance = 1\n", "print(\"epsilon:\", base_discrete_lap.map(d_in=absolute_distance))" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "`make_base_discrete_gaussian` is the analogous measurement for Gaussian noise:" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "noisy aggregate: -1\n", "rho: 0.5\n" ] } ], "source": [ "from opendp.measurements import make_base_discrete_gaussian\n", "\n", "# call the constructor to produce the measurement `base_discrete_gauss`\n", "base_discrete_gauss = make_base_discrete_gaussian(scale=1.)\n", "\n", "# invoke the measurement on some aggregate x, to sample DiscreteGaussian(x, 1.) noise\n", "aggregated = 0\n", "print(\"noisy aggregate:\", base_discrete_gauss(aggregated))\n", "\n", "# we must know the sensitivity of `aggregated` to determine epsilon\n", "absolute_distance = 1\n", "print(\"rho:\", base_discrete_gauss.map(d_in=absolute_distance))" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Domain: Scalar vs. Vector" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Measurements covered thus far have accepted scalar inputs and emitted scalar outputs, \n", "and sensitivities have been expressed in terms of the absolute distance.\n", "\n", "All constructors have an additional argument `D` (short for \"Domain\"), which can be used to configure the shape of the domain that the mechanism operates over.\n", "`D` defaults to `AllDomain`, which represents the space of all (non-null) elements of some type `T` (where `T` is `float` or `int`, depending on the support of the distribution).\n", "\n", "You can instead set `D` to `\"VectorDomain>\"`, (where `T` is `float` or `int`) which indicates that the measurement should be vector-valued." ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "inferred type is f64, expected Vec. See https://github.com/opendp/opendp/discussions/298\n" ] } ], "source": [ "# call again, but this time indicate that the measurement should operate over a vector domain\n", "base_lap_vec = make_base_laplace(\n", " scale=1., D=\"VectorDomain>\"\n", ")\n", "\n", "aggregated = 1.\n", "# If we try to pass the wrong data type into our vector laplace measurement, \n", "# the error shows that our float argument should be a vector of floats.\n", "try:\n", " print(\"noisy aggregate:\", base_lap_vec(aggregated))\n", "except TypeError as e:\n", " # The error messages will often point to a discussion page with more info.\n", " print(e)" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "noisy aggregate: [0.13960776943015754, 1.9918326778096607, 1.7100959620394025]\n" ] } ], "source": [ "# actually pass a vector-valued input, as expected\n", "aggregated = [0., 2., 2.]\n", "print(\"noisy aggregate:\", base_lap_vec(aggregated))\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The resulting measurement expects sensitivity in terms of the appropriate Lp-distance: the vector Laplace measurement expects sensitivity in terms of an `\"L1Distance\"`, while the vector Gaussian measurement expects a sensitivity in terms of an `\"L2Distance\"`. " ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "epsilon: 1.0\n" ] } ], "source": [ "l1_distance = 1.\n", "print(\"epsilon:\", base_lap_vec.map(d_in=l1_distance))" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The documentation for each constructor also reflects the relationship between `D` and the resulting input metric in a table:" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on function make_base_laplace in module opendp.measurements:\n", "\n", "make_base_laplace(scale, k: int = -1074, D: Union[ForwardRef('RuntimeType'), _GenericAlias, str, Type[Union[List, Tuple, int, float, str, bool]], tuple] = 'AllDomain') -> opendp.mod.Measurement\n", " Make a Measurement that adds noise from the laplace(`scale`) distribution to a scalar value.\n", " \n", " Set `D` to change the input data type and input metric:\n", " \n", " | `D` | input type | `D::InputMetric` |\n", " | ---------------------------- | ------------ | ---------------------- |\n", " | `AllDomain` (default) | `T` | `AbsoluteDistance` |\n", " | `VectorDomain>` | `Vec` | `L1Distance` |\n", " \n", " \n", " This function takes a noise granularity in terms of 2^k. \n", " Larger granularities are more computationally efficient, but have a looser privacy map. \n", " If k is not set, k defaults to the smallest granularity.\n", " \n", " [make_base_laplace in Rust documentation.](https://docs.rs/opendp/latest/opendp/measurements/fn.make_base_laplace.html)\n", " \n", " **Supporting Elements:**\n", " \n", " * Input Domain: `D`\n", " * Output Domain: `D`\n", " * Input Metric: `D::InputMetric`\n", " * Output Measure: `MaxDivergence`\n", " \n", " :param scale: Noise scale parameter for the laplace distribution. `scale` == sqrt(2) * standard_deviation.\n", " :param k: The noise granularity in terms of 2^k.\n", " :type k: int\n", " :param D: Domain of the data type to be privatized. Valid values are `VectorDomain>` or `AllDomain`\n", " :type D: :py:ref:`RuntimeTypeDescriptor`\n", " :rtype: Measurement\n", " :raises TypeError: if an argument's type differs from the expected type\n", " :raises UnknownTypeError: if a type argument fails to parse\n", " :raises OpenDPException: packaged error from the core OpenDP library\n", "\n" ] } ], "source": [ "help(make_base_laplace)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Regardless of the choice of `D`, the discrete versions of the measurements still expect integral sensitivities.\n", "A special affordance is made for the vector-valued discrete Gaussian mechanism, which can be configured to expect a float sensitivity instead:" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.999698" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# call again, but this time indicate that the measurement should operate over a vector domain\n", "base_gauss_vec = make_base_discrete_gaussian(\n", " scale=1., D=\"VectorDomain>\", QI=float\n", ")\n", "\n", "base_gauss_vec.map(d_in=1.414)\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Throughout the library, types for distances are labeled with `Q` (because `D` is already taken for domains). The type argument `QI` stands for \"input distance\"." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Bit depth\n", "\n", "By default, all floating-point data types default to 64-bit double-precision (denoted `\"f64\"`), and all integral data types default to 32-bit (denoted `\"i32\"`).\n", "The atomic data type expected by the function and privacy units can be further configured to operate over specific bit-depths by explicitly specifying `\"f32\"` instead of `\"float\"`, or `\"i64\"` instead of `\"int\"`. " ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "# explicitly specify that the...\n", "# * computation should be handled with 32-bit integers, and the\n", "# * privacy analysis be conducted with 64-bit floats\n", "base_discrete_lap_i32 = make_base_discrete_laplace(\n", " scale=1., D=\"AllDomain\", QO=\"f64\"\n", ")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "More information on acceptable data types can be found in the _Utilities > Typing_ section of the User Guide." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Desideratum: Floating-Point Granularity\n", "\n", "The \"continuous\" Laplace and Gaussian measurements convert their float arguments to a rational representation, and then add integer noise to the numerator via the respective discrete distribution. \n", "In the OpenDP Library's default configuration, this rational representation of a float is exact.\n", "Therefore the privacy analysis is as tight as if you were to sample truly continuous noise and then postprocess by rounding to the nearest float. \n", "\n", "For most use-cases the sampling algorithm is sufficiently fast when the rational representation is exact.\n", "That is, when noise is sampled with a granularity of $2^{-1074}$, the same granularity as the distance between subnormal 64-bit floats.\n", "However, the granularity can be adjusted to $2^k$, for some choice of k, for a faster runtime.\n", "Adjusting this parameter comes with a small penalty to the sensitivity (to account for rounding to the nearest rational), and subsequently, to the privacy parameters.\n", "\n", "The following plot shows the resulting distribution for some large choices of k:" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAmEAAADRCAYAAACEoGUXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/d3fzzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAoCElEQVR4nO3de7gcVZnv8e+PhIBIgADxAiQEBVRQBN2Ac0TEMWAQuXjl6gCiGVQcPaiIghDwFmQEnSMzEjUiKiCgYhxAkPugRhIuhkkQCRBIYoBIIISLYMh7/lhrx0rT3bv3TlfX7r1/n+fpJ11Va1W/3btW+u1aq2opIjAzMzOzzlqn6gDMzMzMhiMnYWZmZmYVcBJmZmZmVgEnYWZmZmYVcBJmZmZmVgEnYWZmZmYVcBJm1oSk8yR9ebDub21IukHSh9uwn70kLWpHTP14zRdJ+pWk5ZIuKek1QtK2+fl3JH2xsO2jkh6W9KSkzSS9WdI9efmgMuIpg6Qpkn48wLprfCZVkvQqSXdIWiHp3+psb8uxbtZuI6sOwMxsAN4HvBTYLCJWlv1iEXFs73NJ6wJnAW+KiD/mdacD346Ib5UdSy1J5wGLIuLkTr5u8TMZBE4Aro+InasOxKw/fCbMzLrR1sCfB5KASVrbH58vBdYH5tbEM7d+8dLjsbX4/M2q5CTMhhxJCyR9VtIcSU9J+r6kl0q6MndXXCNpTKH8JZIeyl1bN0nascF+R0u6XtJ/KHm1pN9IWibpbkkfaDHEzXO9FZJulLR14TW+JWmhpCck3SrpLYVtu0manbc9LOmswrY3SfqdpMcl/VHSXv38zF4p6TpJj0r6q6SfSNqksH2BpM9LmifpMUk/kLR+g32dKOne/P7mSXp3zfaPSLqrsP0Nef0Wkn4maamk++t1K+VypwGnAAfn7r9jJK0j6WRJD0h6RNL5kjbO5SfkrsVjJD0IXNdgv5+VtETSXyR9qGbbeZK+LGl74O68+vH8md0LvAL4VY5nPUkb5+NuiaTFue6IvK+j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W6rpN9KEdx6XbSPuVeYuKWcB2kraRNIo0sHJGTZkZwJH5+fuA6zz2xYYwtwkbrtbm2J8BHCJpPUnbANsBt3QobrNSlXYmLPfpHwdcRbokeXpEzJV0OjA7ImYA3wd+lAdaLiM1TLMhyW3Chqu1OfZzuYtJg/hXAh8fqldG2vAj/8genCRNzqfXu7K+Wae061gdbPsxa6d2HJduI+3nJMzMzMysAp62yMzMzKwCTsIGMUlnSvqTpDmSfiFpkxbrTZJ0t6T5kk7s52uOk3S9pHmS5kr65ICCN+uggbaVQv0Bt5lc3+3GBrWq20jeh9tJDXdHDmKS9iFdIbRSSncviYjP9VFnBPBnCtODAIfWTA/SrP7LgZdHxG2SRgO3Age1Wt+sCgNpK4W6a9Vm8j7cbmxQq7qN5P24ndTwmbBBLCKujoiVeXEm6f44fVk9PUhEPAf0Tg/S6msuiYjb8vMVwF1UcHdqs/4YYFvptVZtJr++240NalW3kRyD20kNJ2Hd40PAlS2Uqzc9yIAOckkTgF2APwykvllFWm0rvdrWZsDtxrpCpW0E3E56dcW0RUOZpGuAl9XZdFJE/DKXOYl0f5yfdDCuDYGfAZ+KiCc69bpmjQzWtlLkdmNV6oY2kmNwO8mchFUsIiY22y7pKOBdwNtbvHN6S1N89PGa65IayE8i4uf9qWtWlhLaSq+1bjP59d1urFKDvY3kGNxOCjwwfxCTNAk4C3hrRCxtsc5I0gDKt5MaySzgsIiY22J9AT8ElkXEpwYSt1mnDaStFOquVZvJ+3C7sUGt6jaS9+N2UsNJ2CCWp+9Yj39M4DwzIo5tod47gW/yj+lBvtKP19wD+B/gTmBVXv2FiLiiH6GbddRA20qh/oDbTK7vdmODWtVtJO/D7aSGkzAzMzOzCvjqSDMzM7MKOAkzMzMzq4CTMDMzM7MKOAkzMzMzq4CTMDMzM7MKOAkzMzMzq4CTMDMzM7MKOAkzMzMzq8D/B5nFWPLtGMf6AAAAAElFTkSuQmCC", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "num_samples = 10_000\n", "fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(10, 3))\n", "fig.subplots_adjust(top=0.8)\n", "for axis, k in zip(axes, [1, 0, -1]):\n", " base_lap_vec = make_base_laplace(1., k=k, D=\"VectorDomain>\")\n", " support, counts = np.unique(base_lap_vec([0.] * num_samples), return_counts=True)\n", " axis.bar(support, counts / num_samples)\n", " axis.set_xticks([-2, 0, 2])\n", " axis.set_title(f\"k = {k}; gap = {2**k}\")\n", "axes[0].set_ylabel(\"density\")\n", "fig.suptitle('make_base_laplace for different choices of k', y=0.95);" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The distribution becomes increasingly smooth as k approaches the default value (`-1074`).\n", "\n", "The privacy map still adds a penalization when the sensitivity is zero. \n", "The following table uses this behavior to show the increase in epsilon for some choices of k:" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
ε penaltydetail
k
-10740.000000e+00no penalty
-10734.940656e-324~min float
-1007.888609e-31~2^-100
-15.000000e-01~2^-1
01.000000e+00~2^0
12.000000e+00~2^1
\n", "
" ], "text/plain": [ " ε penalty detail\n", "k \n", "-1074 0.000000e+00 no penalty\n", "-1073 4.940656e-324 ~min float\n", "-100 7.888609e-31 ~2^-100\n", "-1 5.000000e-01 ~2^-1\n", " 0 1.000000e+00 ~2^0\n", " 1 2.000000e+00 ~2^1" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "k = [-1074, -1073, -100, -1, 0, 1]\n", "ε_penalty = [make_base_laplace(scale=1., k=k_i).map(d_in=0.) for k_i in k]\n", "detail = [\"no penalty\", \"~min float\", \"~2^-100\", \"~2^-1\", \"~2^0\", \"~2^1\"]\n", "\n", "import pandas as pd\n", "pd.DataFrame({\"k\": k, \"ε penalty\": ε_penalty, \"detail\": detail}).set_index(\"k\")" ] } ], "metadata": { "kernelspec": { "display_name": "psi", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.13" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "3220da548452ac41acb293d0d6efded0f046fab635503eb911c05f743e930f34" } } }, "nbformat": 4, "nbformat_minor": 2 }