Skip to content

Laplace Distribution¤

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

Calculates the Laplace cumulative density function.

Parameters:

Name Type Description Default
q Union[Float, ArrayLike]

The value at which to evaluate the Plaplace PDF.

required
loc Union[Float, ArrayLike]

The location parameter of the Plaplace PDF. Defaults to 0.0.

0.0
scale Union[Float, ArrayLike]

The scale parameter of the Plaplace PDF. Defaults to 1.0.

1.0
lower_tail Bool

Whether to return the lower tail of the Plaplace PDF. Defaults to True.

True
log_prob Bool

Whether to return the logarithm of the Plaplace PDF. 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 Laplace CDF evaluated at q.

Examples:

>>> plaplace(1.0, 1.0, 1.0)
Array(0.5, dtype=float32, weak_type=True)

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

Computes the quantile of the Laplace distribution.

Parameters:

Name Type Description Default
p Union[Float, ArrayLike]

Quantiles to compute.

required
loc Union[Float, ArrayLike]

Location parameter. Defaults to 0.0.

0.0
scale Union[Float, ArrayLike]

Scale parameter. Defaults to 1.0.

1.0
lower_tail Bool

Whether to compute the lower tail. Defaults to True.

True
log_prob Bool

Whether to compute 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 quantiles of the Laplace distribution.

Examples:

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

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

Calculates the Laplace probability density function for a given x, location and scale.

Parameters:

Name Type Description Default
x Union[Float, ArrayLike]

The value at which to calculate the probability density.

required
loc Union[Float, ArrayLike]

The location parameter. Defaults to 0.0.

0.0
scale Union[Float, ArrayLike]

The scale parameter. Defaults to 1.0.

1.0
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.dtype

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

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

The probability density at the given x.

Examples:

>>> dlaplace(1.0, 1.0, 1.0)
Array(0., dtype=float32, weak_type=True)

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

Generates random Laplace samples from a given key.

Parameters:

Name Type Description Default
key KeyArray

The PRNG key to use for generating the samples.

required
sample_shape Optional[Shape]

The shape of the output array. Defaults to None.

None
loc Union[Float, ArrayLike]

The location parameter of the Laplace distribution. Defaults to 0.0.

0.0
scale Union[Float, ArrayLike]

The scale parameter of the Laplace distribution. Defaults to 1.0.

1.0
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 jnp.dtype

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

<class 'jax.numpy.float64'>

Returns:

Type Description
ArrayLike

An array containing the random Laplace samples.

Examples:

>>> rlaplace(key, (2, 3))
Array([[-0.16134426,  1.6125823 , -0.6615164 ],
        [-1.5528525 , -0.21459664,  0.09816013]], dtype=float32)