Skip to content

Chisquare Distribution¤

stamox.distribution.pchisq(q: Union[Float, ArrayLike], df: Union[Int, Float, ArrayLike], lower_tail = True, log_prob = False, dtype = <class 'jax.numpy.float64'>) -> ArrayLike ¤

Calculates the chi-squared probability density function.

Parameters:

Name Type Description Default
q Union[float, array-like]

The value of the chi-squared variable.

required
df Union[int, float, array-like]

The degrees of freedom.

required
lower_tail bool

Whether to calculate the lower tail (default True).

True
log_prob bool

Whether to return the log probability (default False).

False
dtype dtype

The dtype of the output (default jnp.float_).

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

The chi-squared probability density function.

Examples:

>>> pchisq(2.0, 3)
Array(0.42759317, dtype=float32, weak_type=True)

stamox.distribution.qchisq(p: Union[Float, ArrayLike], df: Union[Int, Float, ArrayLike], lower_tail = True, log_prob = False, dtype = <class 'jax.numpy.float64'>) -> ArrayLike ¤

Computes the inverse of the chi-squared cumulative distribution function.

Parameters:

Name Type Description Default
p Union[Float, ArrayLike]

Probability value or array of probability values.

required
df Union[Int, Float, ArrayLike]

Degrees of freedom.

required
lower_tail bool

If True (default), probabilities are P[X ≤ x], otherwise, P[X > x].

True
log_prob bool

If True, probabilities are given as log(p).

False
dtype dtype

The dtype of the output (default jnp.float_).

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

The quantiles corresponding to the given probabilities.

Examples:

>>> qchisq(0.95, 10)
Array(18.307034, dtype=float32)

stamox.distribution.dchisq(x: Union[Float, ArrayLike], df: Union[Int, Float, ArrayLike], lower_tail = True, log_prob = False, dtype = <class 'jax.numpy.float64'>) -> ArrayLike ¤

Computes the chi-squared distribution.

Parameters:

Name Type Description Default
x Union[Float, ArrayLike]

A float or array-like object representing the values at which to evaluate the chi-squared distribution.

required
df Union[Int, Float, ArrayLike]

The degrees of freedom for the chi-squared distribution.

required
lower_tail

A boolean indicating whether to compute the lower tail of the chi-squared distribution (defaults to True).

True
log_prob

A boolean indicating whether to return the log probability (defaults to False).

False
dtype

The dtype of the output (defaults to float32).

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

The chi-squared distribution evaluated at x.

Examples:

>>> dchisq(2.0, 3)
Array(0.20755368, dtype=float32, weak_type=True)

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

Generates random variates from the chi-squared distribution.

Parameters:

Name Type Description Default
key KeyArray

Random key to generate the random numbers.

required
sample_shape Optional[Shape]

Shape of the output array. Defaults to None.

None
df Union[Int, Float, ArrayLike]

Degrees of freedom. Defaults to None.

None
lower_tail bool

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

True
log_prob bool

Whether to return the log probability. Defaults to False.

False
dtype dtype

The dtype of the output (default float_).

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

Random variates from the chi-squared distribution.

Examples:

>>> key = jax.random.PRNGKey(0)
>>> rchisq(key, df=2)
Array(1.982825, dtype=float32)