class_docstr: Creates a random ill-conditioned Gaussian.
  
  The covariance matrix has eigenvalues sampled from the inverse Gamma
  distribution with the specified shape, and then rotated by a random orthogonal
  matrix.
  
  Note that this function produces reproducible targets, i.e. the constructor
  `seed` argument always needs to be non-`None`.
docstr: Construct the ill-conditioned Gaussian.
  
  Args:
    ndims: Python `int`. Dimensionality of the Gaussian.
    gamma_shape_parameter: Python `float`. The shape parameter of the inverse
      Gamma distribution. Anything below 2 is likely to yield poorly
      conditioned covariance matrices.
    max_eigvalue: Python `float`. If set, will normalize the eigenvalues such
      that the maximum is this value.
    seed: Seed to use when generating the eigenvalues and the random
      orthogonal matrix.
    name: Python `str` name prefixed to Ops created by this class.
    pretty_name: A Python `str`. The pretty name of this model.
docstr_tok: ["Construct","the","ill-conditioned","Gaussian",".","Args",":","ndims",":","Python","`","int","`",".","Dimensionality","of","the","Gaussian",".","gamma_shape_parameter",":","Python","`","float","`",".","The","shape","parameter","of","the","inverse","Gamma","distribution",".","Anything","below","2","is","likely","to","yield","poorly","conditioned","covariance","matrices",".","max_eigvalue",":","Python","`","float","`",".","If","set",",","will","normalize","the","eigenvalues","such","that","the","maximum","is","this","value",".","seed",":","Seed","to","use","when","generating","the","eigenvalues","and","the","random","orthogonal","matrix",".","name",":","Python","`","str","`","name","prefixed","to","Ops","created","by","this","class",".","pretty_name",":","A","Python","`","str","`",".","The","pretty","name","of","this","model","."]
code: def __init__(
      self,
      ndims=100,
      gamma_shape_parameter=0.5,
      max_eigvalue=None,
      seed=10,
      name="ill_conditioned_gaussian",
      pretty_name="Ill-Conditioned Gaussian",
  ):
      """Construct the ill-conditioned Gaussian.
  
      Args:
        ndims: Python `int`. Dimensionality of the Gaussian.
        gamma_shape_parameter: Python `float`. The shape parameter of the inverse
          Gamma distribution. Anything below 2 is likely to yield poorly
          conditioned covariance matrices.
        max_eigvalue: Python `float`. If set, will normalize the eigenvalues such
          that the maximum is this value.
        seed: Seed to use when generating the eigenvalues and the random
          orthogonal matrix.
        name: Python `str` name prefixed to Ops created by this class.
        pretty_name: A Python `str`. The pretty name of this model.
      """
      rng = np.random.RandomState(seed=seed & (2**32 - 1))
      eigenvalues = 1.0 / np.sort(
          rng.gamma(shape=gamma_shape_parameter, scale=1.0, size=ndims)
      )
      if max_eigvalue is not None:
          eigenvalues *= max_eigvalue / eigenvalues.max()
  
      q, r = np.linalg.qr(rng.randn(ndims, ndims))
      q *= np.sign(np.diag(r))
  
      covariance = (q * eigenvalues).dot(q.T)
  
      gaussian = tfd.MultivariateNormalTriL(
          loc=tf.zeros(ndims),
          scale_tril=tf.linalg.cholesky(
              tf.convert_to_tensor(covariance, dtype=tf.float32)
          ),
      )
      self._eigenvalues = eigenvalues
  
      sample_transformations = {
          "identity": model.Model.SampleTransformation(
              fn=lambda params: params,
              pretty_name="Identity",
              ground_truth_mean=np.zeros(ndims),
              ground_truth_standard_deviation=np.sqrt(
                  np.diag(covariance)
              ),
          )
      }
  
      self._gaussian = gaussian
  
      super(IllConditionedGaussian, self).__init__(
          default_event_space_bijector=tfb.Identity(),
          event_shape=gaussian.event_shape,
          dtype=gaussian.dtype,
          name=name,
          pretty_name=pretty_name,
          sample_transformations=sample_transformations,
      )
  
file_path: probability/spinoffs/inference_gym/inference_gym/targets/ill_conditioned_gaussian.py
imports: import numpy
  import tensorflow.compat.v2
  import tensorflow_probability
  from inference_gym.targets import model
label_desc: Use image node_id 1 to create a new IllConditionedGaussian object from inherited base classes: model with example: obj = IllConditionedGaussian(ndims, gamma_shape_parameter, max_eigvalue, seed, name, pretty_name)