opendp.meas module#

opendp.meas.make_base_gaussian(scale, D='AllDomain<T>')[source]#

Make a Measurement that adds noise from the gaussian(scale) distribution to the input. Adjust D to noise vector-valued data.

Parameters:
  • scale – noise scale parameter to the gaussian distribution

  • D (RuntimeTypeDescriptor) – Domain of the data type to be privatized. Valid values are VectorDomain<AllDomain<T>> or AllDomain<T>

Returns:

A base_gaussian step.

Return type:

Measurement

Raises:
  • AssertionError – if an argument’s type differs from the expected type

  • UnknownTypeError – if a type-argument fails to parse

  • OpenDPException – packaged error from the core OpenDP library

opendp.meas.make_base_geometric(scale, bounds=None, D='AllDomain<i32>', QO=None)[source]#

Make a Measurement that adds noise from the geometric(scale) distribution to the input. Adjust D to noise vector-valued data.

Parameters:
  • scale – noise scale parameter to the geometric distribution

  • bounds (Any) – Set bounds on the count to make the algorithm run in constant-time.

  • D (RuntimeTypeDescriptor) – Domain of the data type to be privatized. Valid values are VectorDomain<AllDomain<T>> or AllDomain<T>

  • QO (RuntimeTypeDescriptor) – Data type of the sensitivity, scale, and budget.

Returns:

A base_geometric step.

Return type:

Measurement

Raises:
  • AssertionError – if an argument’s type differs from the expected type

  • UnknownTypeError – if a type-argument fails to parse

  • OpenDPException – packaged error from the core OpenDP library

opendp.meas.make_base_laplace(scale, D='AllDomain<T>')[source]#

Make a Measurement that adds noise from the laplace(scale) distribution to a scalar value. Adjust D to noise vector-valued data.

This constructor is supported by the linked proof.

Parameters:
  • scale – Noise scale parameter of the laplace distribution.

  • D (RuntimeTypeDescriptor) – Domain of the data type to be privatized. Valid values are VectorDomain<AllDomain<T>> or AllDomain<T>

Returns:

A base_laplace step.

Return type:

Measurement

Raises:
  • AssertionError – if an argument’s type differs from the expected type

  • UnknownTypeError – if a type-argument fails to parse

  • OpenDPException – packaged error from the core OpenDP library

opendp.meas.make_base_stability(size, scale, threshold, MI, TIK, TIC='i32')[source]#

Make a Measurement that implements a stability-based filtering and noising.

Parameters:
  • size (int) – Number of records in the input vector.

  • scale – Noise scale parameter.

  • threshold – Exclude counts that are less than this minimum value.

  • MI (SensitivityMetric) – Input metric.

  • TIK (RuntimeTypeDescriptor) – Data type of input key- must be hashable/categorical.

  • TIC (RuntimeTypeDescriptor) – Data type of input count- must be integral.

Returns:

A base_stability step.

Return type:

Measurement

Raises:
  • AssertionError – if an argument’s type differs from the expected type

  • UnknownTypeError – if a type-argument fails to parse

  • OpenDPException – packaged error from the core OpenDP library