Skip to content

Binomial Distribution¤

stamox.distribution.pbinom(q: ArrayLike, size: ArrayLike, prob: ArrayLike, lower_tail: Bool = True, log_prob: Bool = False, dtype = <class 'jax.numpy.float64'>) -> ArrayLike ¤

Calculates the cumulative probability of a binomial distribution.

Parameters:

Name Type Description Default
q ArrayLike

The quantiles to compute.

required
size ArrayLike

The number of trials.

required
prob ArrayLike

The probability of success in each trial.

required
lower_tail Bool

If True (default), the lower tail probability is returned.

True
log_prob Bool

If True, the logarithm of the probability is returned.

False
dtype optional

The data type of the output array. Defaults to jnp.float_.

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

The cumulative probability of the binomial distribution.

Examples:

>>> q = jnp.array([0.1, 0.5, 0.9])
>>> size = 10
>>> prob = 0.5
>>> pbinom(q, size, prob)

stamox.distribution.qbinom(p: ArrayLike, size: ArrayLike, prob: ArrayLike, lower_tail: Bool = True, log_prob: Bool = False, dtype = <class 'jax.numpy.int64'>) -> ArrayLike ¤

Computes the quantile of a binomial distribution.

Parameters:

Name Type Description Default
p ArrayLike

The probability of success.

required
size ArrayLike

The number of trials.

required
prob ArrayLike

The probability of success in each trial.

required
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.int_

The data type of the output array. Defaults to jnp.int_.

<class 'jax.numpy.int64'>

Returns:

Type Description
ArrayLike

The quantile of the binomial distribution.

Examples:

>>> p = jnp.array([0.1, 0.5, 0.9])
>>> size = 10
>>> prob = 0.5
>>> qbinom(p, size, prob)

stamox.distribution.dbinom(q: ArrayLike, size: ArrayLike, prob: ArrayLike, lower_tail: Bool = True, log_prob: Bool = False, dtype = <class 'jax.numpy.float64'>) -> ArrayLike ¤

Computes the probability of a binomial distribution.

Parameters:

Name Type Description Default
q ArrayLike

The value to compute the probability for.

required
size ArrayLike

The number of trials in the binomial distribution.

required
prob ArrayLike

The probability of success in each trial.

required
lower_tail Bool

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

True
log_prob Bool

Whether to return the logarithm of the probability. Defaults to False.

False
dtype jnp.float_

The data type of the output array. Defaults to jnp.float_.

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

The probability of the binomial distribution.

Examples:

>>> q = jnp.array([0.1, 0.5, 0.9])
>>> size = 10
>>> prob = 0.5
>>> dbinom(q, size, prob)

stamox.distribution.rbinom(key: Union[jax.Array, jax._src.prng.PRNGKeyArray], sample_shape: Optional[Sequence[int]] = None, size: ArrayLike = None, prob: ArrayLike = None, lower_tail: Bool = True, log_prob: Bool = False, dtype = <class 'jax.numpy.int64'>) -> ArrayLike ¤

Generates random binomial samples from a given probability distribution.

Parameters:

Name Type Description Default
key KeyArray

A random number generator key.

required
sample_shape Optional[Shape]

The shape of the output array. Defaults to None.

None
size ArrayLike

The number of trials. Defaults to None.

None
prob ArrayLike

The probability of success for each trial. Defaults to None.

None
lower_tail Bool

Whether to return the lower tail of the distribution. Defaults to True.

True
log_prob Bool

Whether to return the logarithm of the probability. Defaults to False.

False
dtype jnp.float32

The data type of the output array. Defaults to jnp.float32.

<class 'jax.numpy.int64'>

Returns:

Type Description
ArrayLike

An array containing the random binomial samples.

Examples:

>>> key = jax.random.PRNGKey(0)
>>> sample_shape = (3, 3)
>>> size = 10
>>> prob = 0.5
>>> rbinom(key, sample_shape, size, prob)