tf.compat.v1.distributions.Uniform

Uniform distribution with low and high parameters.

Inherits From: Distribution

Mathematical Details

The probability density function (pdf) is,

pdf(x; a, b) = I[a <= x < b] / Z
Z = b - a

where

  • low = a,
  • high = b,
  • Z is the normalizing constant, and
  • I[predicate] is the indicator function for predicate.

The parameters low and high must be shaped in a way that supports broadcasting (e.g., high - low is a valid operation).

Examples

# Without broadcasting:
u1 = Uniform(low=3.0, high=4.0)  # a single uniform distribution [3, 4]
u2 = Uniform(low=[1.0, 2.0],
             high=[3.0, 4.0])  # 2 distributions [1, 3], [2, 4]
u3 = Uniform(low=[[1.0, 2.0],
                  [3.0, 4.0]],
             high=[[1.5, 2.5],
                   [3.5, 4.5]])  # 4 distributions
# With broadcasting:
u1 = Uniform(low=3.0, high=[5.0, 6.0, 7.0])  # 3 distributions

low Floating point tensor, lower boundary of the output interval. Must have low < high.
high Floating point tensor, upper boundary of the output interval. Must have low < high.
validate_args Python bool, default False. When True distribution parameters are checked for validity despite possibly degrading runtime performance. When False invalid inputs may silently render incorrect outputs.
allow_nan_stats Python bool, default True. When True, statistics (e.g., mean, mode, variance) use the value "NaN" to indicate the result is undefined. When False, an exception is raised if one or more of the statistic's batch members are undefined.
name Python str name prefixed to Ops created by this class.

InvalidArgumentError if low >= high and validate_args=False.

allow_nan_stats Python bool describing behavior when a stat is undefined.

Stats return +/- infinity when it makes sense. E.g., the variance of a Cauchy distribution is infinity. However