Class GaussianNoise

  • All Implemented Interfaces:
    Noise

    public class GaussianNoise
    extends java.lang.Object
    implements Noise
    Generates and adds Gaussian noise to a raw piece of numerical data such that the result is securely differentially private.

    The Gaussian noise is generated according to the binomial sampling mechanism described here. This approach is robust against unintentional privacy leaks due to artifacts of floating point arithmetic.

    • Constructor Summary

      Constructors 
      Constructor Description
      GaussianNoise()
      Returns a Noise instance initialized with a secure randomness source.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double addNoise​(double x, int l0Sensitivity, double lInfSensitivity, double epsilon, java.lang.Double delta)
      Adds Gaussian noise to x such that the output is (epsilon, delta)-differentially private, with respect to the specified L_0 and L_inf sensitivities.
      long addNoise​(long x, int l0Sensitivity, long lInfSensitivity, double epsilon, java.lang.Double delta)
      Adds Gaussian noise to the integer x such that the output is (epsilon, delta)-differentially private, with respect to the specified L_0 and L_inf sensitivities.
      ConfidenceInterval computeConfidenceInterval​(double noisedX, int l0Sensitivity, double lInfSensitivity, double epsilon, java.lang.Double delta, double alpha)
      Computes a confidence interval that contains the raw value x passed to addNoise(double, int, double, double, Double) with a probability equal to 1 - alpha based on the specified noisedX and noise parameters.
      ConfidenceInterval computeConfidenceInterval​(long noisedX, int l0Sensitivity, long lInfSensitivity, double epsilon, java.lang.Double delta, double alpha)
      Computes a confidence interval that contains the raw integer value x passed to addNoise(long, int, long, double, Double) with a probability greater or equal to 1 - alpha based on the specified noisedX and noise parameters.
      double computeQuantile​(double rank, double x, int l0Sensitivity, double lInfSensitivity, double epsilon, java.lang.Double delta)
      Computes the quantile z satisfying Pr[Y <= z] = rank for a Gaussian random variable Y with mean x and variance according to the specified privacy parameters.
      com.google.differentialprivacy.SummaryOuterClass.MechanismType getMechanismType()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GaussianNoise

        public GaussianNoise()
        Returns a Noise instance initialized with a secure randomness source.
    • Method Detail

      • addNoise

        public double addNoise​(double x,
                               int l0Sensitivity,
                               double lInfSensitivity,
                               double epsilon,
                               java.lang.Double delta)
        Adds Gaussian noise to x such that the output is (epsilon, delta)-differentially private, with respect to the specified L_0 and L_inf sensitivities.
        Specified by:
        addNoise in interface Noise
      • addNoise

        public long addNoise​(long x,
                             int l0Sensitivity,
                             long lInfSensitivity,
                             double epsilon,
                             @Nullable
                             java.lang.Double delta)
        Adds Gaussian noise to the integer x such that the output is (epsilon, delta)-differentially private, with respect to the specified L_0 and L_inf sensitivities.
        Specified by:
        addNoise in interface Noise
      • getMechanismType

        public com.google.differentialprivacy.SummaryOuterClass.MechanismType getMechanismType()
        Specified by:
        getMechanismType in interface Noise
      • computeConfidenceInterval

        public ConfidenceInterval computeConfidenceInterval​(double noisedX,
                                                            int l0Sensitivity,
                                                            double lInfSensitivity,
                                                            double epsilon,
                                                            java.lang.Double delta,
                                                            double alpha)
        Computes a confidence interval that contains the raw value x passed to addNoise(double, int, double, double, Double) with a probability equal to 1 - alpha based on the specified noisedX and noise parameters.

        Refer to this doc for more information.

        Specified by:
        computeConfidenceInterval in interface Noise
      • computeConfidenceInterval

        public ConfidenceInterval computeConfidenceInterval​(long noisedX,
                                                            int l0Sensitivity,
                                                            long lInfSensitivity,
                                                            double epsilon,
                                                            java.lang.Double delta,
                                                            double alpha)
        Computes a confidence interval that contains the raw integer value x passed to addNoise(long, int, long, double, Double) with a probability greater or equal to 1 - alpha based on the specified noisedX and noise parameters.

        Refer to this doc for more information.

        Specified by:
        computeConfidenceInterval in interface Noise
      • computeQuantile

        public double computeQuantile​(double rank,
                                      double x,
                                      int l0Sensitivity,
                                      double lInfSensitivity,
                                      double epsilon,
                                      @Nullable
                                      java.lang.Double delta)
        Computes the quantile z satisfying Pr[Y <= z] = rank for a Gaussian random variable Y with mean x and variance according to the specified privacy parameters.
        Specified by:
        computeQuantile in interface Noise