HalfCauchyPrior

phasic.svgd.HalfCauchyPrior(scale=None, ci=None, prob=0.95)

Half-Cauchy prior distribution (positive support only).

The prior is defined in THETA space (the natural parameter space). When used with positive_params=True, SVGD automatically handles the transformation to PHI space with proper Jacobian correction.

Useful for scale parameters due to heavy tails. PDF: f(θ) = 2 / (π × scale × (1 + (θ/scale)²)) for θ > 0

Parameters

scale : float = None

Scale parameter of the half-Cauchy distribution. Mutually exclusive with ci.

ci : float = None

Upper bound of the credible interval. The scale is computed such that P(θ < ci) = prob. Mutually exclusive with scale.

prob : float = 0.95

Coverage probability for the credible interval (only used with ci). E.g., prob=0.95 means 95% of the prior mass is below ci.

Examples

>>> # Specify scale directly
>>> prior = HalfCauchyPrior(scale=2.0)
>>>
>>> # Specify via 95% CI upper bound
>>> prior = HalfCauchyPrior(ci=10.0)  # 95% of mass below 10
>>>
>>> # Specify via 90% CI upper bound
>>> prior = HalfCauchyPrior(ci=10.0, prob=0.90)
>>>
>>> # Plot to verify prior matches your beliefs
>>> prior.plot()
>>>
>>> # Use in SVGD
>>> svgd = graph.svgd(data, theta_dim=1, prior=prior)

Methods

Name Description
plot Plot the half-Cauchy prior distribution in THETA space.
sample Sample from the prior.

plot

phasic.svgd.HalfCauchyPrior.plot(
    ax=None,
    show_ci=True,
    return_ax=False,
    **kwargs,
)

Plot the half-Cauchy prior distribution in THETA space.

Parameters

ax : matplotlib.axes.Axes = None

Axes to plot on. If None, creates new figure.

show_ci : bool = True

If True and ci was specified, show vertical line at CI bound.

return_ax : bool = False

If True, return ax. If False, call plt.show() instead.

****kwargs** : = {}

Additional arguments passed to plot function.

Returns

: matplotlib.axes.Axes

The axes with the plot (only if return_ax=False)

sample

phasic.svgd.HalfCauchyPrior.sample(key, shape)

Sample from the prior.

When _transform is set, samples in THETA space and converts to PHI space.

Parameters

key : jax.random.PRNGKey

Random key

shape : tuple

Shape of samples (n_particles, theta_dim)

Returns

: array

Samples (in PHI space if transform is set)