class_docstr: LKJ distribution for lower Cholesky factor of correlation matrices.
  The distribution is controlled by ``concentration`` parameter :math:`\eta`
  to make the probability of the correlation matrix :math:`M` generated from
  a Cholesky factor proportional to :math:`\det(M)^{\eta - 1}`. Because of that,
  when ``concentration == 1``, we have a uniform distribution over Cholesky
  factors of correlation matrices::
  
      L ~ LKJCholesky(dim, concentration)
      X = L @ L' ~ LKJCorr(dim, concentration)
  
  Note that this distribution samples the
  Cholesky factor of correlation matrices and not the correlation matrices
  themselves and thereby differs slightly from the derivations in [1] for
  the `LKJCorr` distribution. For sampling, this uses the Onion method from
  [1] Section 3.
  
  Example::
  
      >>> # xdoctest: +IGNORE_WANT("non-deterministic")
      >>> l = LKJCholesky(3, 0.5)
      >>> l.sample()  # l @ l.T is a sample of a correlation 3x3 matrix
      tensor([[ 1.0000,  0.0000,  0.0000],
              [ 0.3516,  0.9361,  0.0000],
              [-0.1899,  0.4748,  0.8593]])
  
  Args:
      dimension (dim): dimension of the matrices
      concentration (float or Tensor): concentration/shape parameter of the
          distribution (often referred to as eta)
  
  **References**
  
  [1] `Generating random correlation matrices based on vines and extended onion method` (2009),
  Daniel Lewandowski, Dorota Kurowicka, Harry Joe.
  Journal of Multivariate Analysis. 100. 10.1016/j.jmva.2009.04.008
class_docstr_tok: ["LKJ","distribution","for","lower","Cholesky","factor","of","correlation","matrices",".","The","distribution","is","controlled","by","``","concentration","``","parameter",":","math",":","`","\\eta","`","to","make","the","probability","of","the","correlation","matrix",":","math",":","`","M","`","generated","from","a","Cholesky","factor","proportional","to",":","math",":","`","\\det","(","M",")","^","{","\\eta","-","1","}","`",".","Because","of","that",",","when","``","concentration","==","1","``",",","we","have","a","uniform","distribution","over","Cholesky","factors","of","correlation","matrices",":",":","L","~","LKJCholesky","(","dim",",","concentration",")","X","=","L","@","L","'","~","LKJCorr","(","dim",",","concentration",")","Note","that","this","distribution","samples","the","Cholesky","factor","of","correlation","matrices","and","not","the","correlation","matrices","themselves","and","thereby","differs","slightly","from","the","derivations","in","[","1","]","for","the","`","LKJCorr","`","distribution",".","For","sampling",",","this","uses","the","Onion","method","from","[","1","]","Section","3",".","Example",":",":",">",">",">","#","xdoctest",":","+IGNORE_WANT","(","``","non-deterministic","''",")",">",">",">","l","=","LKJCholesky","(","3",",","0.5",")",">",">",">","l.sample","(",")","#","l","@","l.T","is","a","sample","of","a","correlation","3x3","matrix","tensor","(","[","[","1.0000",",","0.0000",",","0.0000","]",",","[","0.3516",",","0.9361",",","0.0000","]",",","[","-0.1899",",","0.4748",",","0.8593","]","]",")","Args",":","dimension","(","dim",")",":","dimension","of","the","matrices","concentration","(","float","or","Tensor",")",":","concentration\/shape","parameter","of","the","distribution","(","often","referred","to","as","eta",")","*","*","References","*","*","[","1","]","`","Generating","random","correlation","matrices","based","on","vines","and","extended","onion","method","`","(","2009",")",",","Daniel","Lewandowski",",","Dorota","Kurowicka",",","Harry","Joe",".","Journal","of","Multivariate","Analysis",".","100",".","10.1016\/j.jmva.2009.04.008"]
code: def __init__(self, dim, concentration=1.0, validate_args=None):
      if dim < 2:
          raise ValueError(
              f"Expected dim to be an integer greater than or equal to 2. Found dim={dim}."
          )
      self.dim = dim
      (self.concentration,) = broadcast_all(concentration)
      batch_shape = self.concentration.size()
      event_shape = torch.Size((dim, dim))
      # This is used to draw vectorized samples from the beta distribution in Sec. 3.2 of [1].
      marginal_conc = self.concentration + 0.5 * (self.dim - 2)
      offset = torch.arange(
          self.dim - 1,
          dtype=self.concentration.dtype,
          device=self.concentration.device,
      )
      offset = torch.cat([offset.new_zeros((1,)), offset])
      beta_conc1 = offset + 0.5
      beta_conc0 = marginal_conc.unsqueeze(-1) - 0.5 * offset
      self._beta = Beta(beta_conc1, beta_conc0)
      super().__init__(batch_shape, event_shape, validate_args)
  
file_path: pytorch/torch/distributions/lkj_cholesky.py
imports: import math
  import torch
  from torch.distributions import Beta, constraints
  from torch.distributions.distribution import Distribution
  from torch.distributions.utils import broadcast_all
label_desc: Use image node_id 1 to create a new LKJCholesky object from inherited base classes: Distribution with example: obj = LKJCholesky(dim, concentration, validate_args)