L i tddlmZmZddlZddlmZddlmZddlmZddl m Z ddl m Z dgZ Gd de Zy) )OptionalUnionN)Tensor) constraints)Gamma)TransformedDistribution)PowerTransform InverseGammac ,eZdZUdZej ej dZej ZdZe e d< dde e e fde e e fdeed dffd Zdfd Zed e fd Zed e fd Zed e fdZed e fdZed e fdZdZxZS)r a Creates an inverse gamma distribution parameterized by :attr:`concentration` and :attr:`rate` where:: X ~ Gamma(concentration, rate) Y = 1 / X ~ InverseGamma(concentration, rate) Example:: >>> # xdoctest: +IGNORE_WANT("non-deterinistic") >>> m = InverseGamma(torch.tensor([2.0]), torch.tensor([3.0])) >>> m.sample() tensor([ 1.2953]) Args: concentration (float or Tensor): shape parameter of the distribution (often referred to as alpha) rate (float or Tensor): rate = 1 / scale of the distribution (often referred to as beta) ) concentrationrateT base_distNr r validate_argsreturnct|||}|jjd }t||t ||y)N)r)rr new_onessuper__init__r )selfr r rrneg_one __class__s g/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/distributions/inverse_gamma.pyrzInverseGamma.__init__-sH -]K >>**2..  ~g.m  cR|jt|}t| ||S)N) _instance)_get_checked_instancer rexpand)r batch_shapernewrs rrzInverseGamma.expand9s(((yAw~kS~99rc.|jjSN)rr rs rr zInverseGamma.concentration=s~~+++rc.|jjSr")rr r#s rr zInverseGamma.rateAs~~"""rc|j|jdz z }tj|jdkD|tjSN)r r torchwhereinfrresults rmeanzInverseGamma.meanEs=d00145{{4--16599EErc:|j|jdzz Sr&)r r r#s rmodezInverseGamma.modeJsyyD..233rc|jj|jdz j|jdz zz }tj|jdkD|tj S)Nr')r squarer r(r)r*r+s rvariancezInverseGamma.varianceNsd!!#   ! # + + -1C1Ca1G H {{4--16599EErc|j|jjz|jjzd|jz|jj zz Sr&)r r loglgammadigammar#s rentropyzInverseGamma.entropyUsc   iimmo   '') *4%%%););)C)C)EE F rr")__name__ __module__ __qualname____doc__rpositivearg_constraintssupport has_rsampler__annotations__rrfloatrboolrrpropertyr r r-r/r3r8 __classcell__)rs@rr r s,%--$$O""GK )-  VU]+  FEM"   ~    :,v,,#f##FfFF4f44F&FF  r)typingrrr(rtorch.distributionsrtorch.distributions.gammar,torch.distributions.transformed_distributionrtorch.distributions.transformsr __all__r rrrrLs3" ++P9  L *L r