LKJCholesky
DistributionLKJCholesky(dim: int, concentration: Tensor | float = 1.0, validate_args: bool | None = None)LKJ distribution over Cholesky factors of correlation matrices.
Generative prior for the lower-triangular Cholesky factor of a correlation matrix of size . Density is proportional to so the parameter ("concentration") controls how concentrated the prior is around the identity (uncorrelated). Widely used as a weakly-informative prior on correlation structure in Bayesian hierarchical models — replacing an inverse-Wishart prior (which couples scale and correlation) with a clean separation.
Parameters
dimintconcentrationTensor or float= 1.01.0 (uniform over
the space of correlation matrices). concentrates
mass near the identity (low correlation),
favours high-correlation factors.validate_argsbool= NoneTrue, validate parameter constraints at construction.Notes
Probability density on the manifold of valid Cholesky factors :
where the second equality follows from the Jacobian of the transformation between and its Cholesky factor.
Sampling uses the vectorised Onion method (Lewandowski, Kurowicka & Joe, 2009, §3) — row is built incrementally so that its squared norm equals one, with off-diagonal magnitude drawn from a Beta and angular components from a uniform on the sphere. The full sampler runs in per draw with no rejections.
For the distribution is uniform over valid correlation matrices (specifically, over the set of valid Cholesky factors).
Examples
>>> import lucid
>>> from lucid.distributions import LKJCholesky
>>> dist = LKJCholesky(dim=4, concentration=2.0)
>>> L = dist.sample() # (4, 4) lower-triangular Cholesky factor
>>> R = L @ L.T # implied correlation matrix
>>> R.diagonal() # diagonal of R is all 1's
Tensor([1., 1., 1., 1.])
Use as a Bayesian prior over correlation structure:
>>> prior = LKJCholesky(dim=8, concentration=1.5)
>>> # ... pair with marginal scales / standard deviations to form a
>>> # covariance prior: Σ = diag(σ) · R · diag(σ)Methods (4)
__init__
→None__init__(dim: int, concentration: Tensor | float = 1.0, validate_args: bool | None = None)Initialise an LKJ distribution over Cholesky factors.
Pre-computes the Beta distribution parameters used by the vectorised Onion sampler (Lewandowski et al. 2009, §3).
Parameters
dimintconcentrationTensor | float= 1.01.0 (uniform
distribution over correlation matrices). Larger values concentrate
mass near the identity (near-zero correlations).validate_argsbool | None= NoneTrue, validate parameter constraints at construction time.support
→Constraintsupport: ConstraintConstraint: positive-definite matrices (proxy for correlation-Cholesky support).
sample
→Tensorsample(sample_shape: tuple[int, ...] = ())Draw a sample via the vectorised Onion method (Lewandowski 2009 §3).
Returns the lower Cholesky factor L of a random correlation matrix.
log_prob
→Tensorlog_prob(value: Tensor)Log-density of the LKJ distribution on a Cholesky factor.
The density is proportional to
∏_{i=2}^{d} L_{ii}^{order_i}
where order_i = 2(η − 1) + (d − i).
The normaliser follows Eq. (15) of Lewandowski et al. (2009).