ClipGaussianJitter#

class ClipGaussianJitter(scalar=0.02, store_jitter=False)[source]#

Bases: object

Add isotropic clipped multivariate-Gaussian noise to coord.

Samples 3D noise from a standard multivariate normal, clips it to roughly +/- 1.96 sigma (the stored quantile), scales by scalar, and adds it to coord in place. Optionally records the applied noise under the jitter key. Requires coord; a no-op if coord is absent. Registered as ClipGaussianJitter – use this string as the type in a transform=[...] config list.

Parameters:
  • scalar (float) – multiplier applied to the clipped unit noise, setting the jitter magnitude. Defaults to 0.02.

  • store_jitter (bool) – if True, save the applied per-point noise under data_dict["jitter"]. Defaults to False.

Note

Assumes 3D coordinates (the noise covariance is the 3x3 identity).

Example

>>> import numpy as np
>>> from pimm.datasets.transform import ClipGaussianJitter
>>> data = {"coord": np.zeros((2, 3), dtype="f4")}
>>> # NOTE: as written the constructor sets mean = np.mean(3) (a scalar),
>>> # so the multivariate-normal draw raises before any jitter is applied:
>>> ClipGaussianJitter(scalar=0.02)(data)
Traceback (most recent call last):
    ...
ValueError: mean must be 1 dimensional