Skip to content

Uniform Distribution¤

stamox.distribution.punif(q: Union[Float, ArrayLike], mini: Union[Float, ArrayLike] = 0.0, maxi: Union[Float, ArrayLike] = 1.0, lower_tail: Bool = True, log_prob: Bool = False, dtype = <class 'jax.numpy.float64'>) -> ArrayLike ¤

Computes the cumulative distribution function of the uniform distribution.

Parameters:

Name Type Description Default
q Union[Float, ArrayLike]

The value at which to evaluate the CDF.

required
mini Union[Float, ArrayLike]

The minimum value of the uniform distribution. Defaults to 0.0.

0.0
maxi Union[Float, ArrayLike]

The maximum value of the uniform distribution. Defaults to 1.0.

1.0
lower_tail bool

Whether to compute the lower tail of the CDF. Defaults to True.

True
log_prob bool

Whether to return the log probability. Defaults to False.

False
dtype jnp.dtype

The dtype of the output. Defaults to jnp.float_.

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

The cumulative distribution function of the uniform distribution evaluated at q.

Examples:

>>> punif(0.5)
Array(0.5, dtype=float32, weak_type=True)

stamox.distribution.qunif(p: Union[Float, ArrayLike], mini: Union[Float, ArrayLike] = 0.0, maxi: Union[Float, ArrayLike] = 1.0, lower_tail: Bool = True, log_prob: Bool = False, dtype = <class 'jax.numpy.float64'>) -> ArrayLike ¤

Computes the quantile function of a uniform distribution.

Parameters:

Name Type Description Default
p Union[Float, ArrayLike]

Quantiles to compute.

required
mini Union[Float, Array]

Lower bound of the uniform distribution. Defaults to 0.0.

0.0
maxi Union[Float, Array]

Upper bound of the uniform distribution. Defaults to 1.0.

1.0
lower_tail Bool

Whether to compute the lower tail or not. Defaults to True.

True
log_prob Bool

Whether to compute the log probability or not. Defaults to False.

False
dtype jnp.dtype

The dtype of the output. Defaults to jnp.float_.

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

The quantiles of the uniform distribution.

Examples:

>>> qunif(0.5)
Array(0.5, dtype=float32, weak_type=True)

stamox.distribution.dunif(x: Union[Float, ArrayLike], mini: Union[Float, ArrayLike] = 0.0, maxi: Union[Float, ArrayLike] = 1.0, lower_tail: Bool = True, log_prob: Bool = False, dtype = <class 'jax.numpy.float64'>) -> ArrayLike ¤

Calculates the probability density function of a uniform distribution.

Parameters:

Name Type Description Default
x Union[Float, ArrayLike]

The value or array of values for which to calculate the probability density.

required
mini Union[Float, Array]

The lower bound of the uniform distribution. Defaults to 0.0.

0.0
maxi Union[Float, Array]

The upper bound of the uniform distribution. Defaults to 1.0.

1.0
lower_tail Bool

Whether to calculate the lower tail probability. Defaults to True.

True
log_prob Bool

Whether to return the log probability. Defaults to False.

False
dtype jnp.dtype

The dtype of the output. Defaults to jnp.float_.

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

The probability density of the given value(s).

Examples:

>>> dunif(0.5)
Array(1., dtype=float32, weak_type=True)

stamox.distribution.runif(key: Union[jax.Array, jax._src.prng.PRNGKeyArray], sample_shape: Optional[Sequence[int]] = None, mini: Union[Float, ArrayLike] = 0.0, maxi: Union[Float, ArrayLike] = 1.0, lower_tail: Bool = True, log_prob: Bool = False, dtype = <class 'jax.numpy.float64'>) -> ArrayLike ¤

Generates random numbers from a uniform distribution.

Parameters:

Name Type Description Default
key Union[jax.Array, jax._src.prng.PRNGKeyArray]

A PRNGKey to use for generating the random numbers.

required
sample_shape Optional[Sequence[int]]

The shape of the output array.

None
mini Union[Float, ArrayLike]

The minimum value of the uniform distribution.

0.0
maxi Union[Float, ArrayLike]

The maximum value of the uniform distribution.

1.0
lower_tail Bool

Whether to generate values from the lower tail of the distribution.

True
log_prob Bool

Whether to return the log probability of the generated values.

False
dtype

The dtype of the output. Defaults to jnp.float_.

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

An array of random numbers from a uniform distribution.

Examples:

>>> runif(key, sample_shape=(2, 3))
Array([[0.57450044, 0.09968603, 0.7419659 ],
        [0.8941783 , 0.59656656, 0.45325184]], dtype=float32)