ott.solvers.utils.uniform_sampler

ott.solvers.utils.uniform_sampler#

ott.solvers.utils.uniform_sampler(rng, num_samples, low=0.0, high=1.0, offset=None)[source]#

Sample from a uniform distribution.

Sample \(t\) from a uniform distribution \([low, high]\). If offset is not None, one element \(t\) is sampled from \([low, high]\) and the K samples are constructed via \((t + k)/K \mod (high - low - offset) + low\).

Parameters:
  • rng (Array) – Random number generator.

  • num_samples (int) – Number of samples to generate.

  • low (float) – Lower bound of the uniform distribution.

  • high (float) – Upper bound of the uniform distribution.

  • offset (Optional[float]) – Offset of the uniform distribution. If None, no offset is used.

Return type:

Array

Returns:

An array of shape [num_samples, 1].