
    ȅi
                     d    S SK r S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S/r
 " S S\5      rg)	    N)Tensor)constraints)Gamma)TransformedDistribution)PowerTransformInverseGammac            	       @  ^  \ rS rSr% Sr\R                  \R                  S.r\R                  rSr	\
\S'    SS\\-  S\\-  S	\S-  S
S4U 4S jjjrSU 4S jjr\S
\4S j5       r\S
\4S j5       r\S
\4S j5       r\S
\4S j5       r\S
\4S j5       rS rSrU =r$ )r      aD  
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)
)concentrationrateT	base_distNr   r   validate_argsreturnc                    > [        XUS9nUR                  R                  S5      * n[        TU ]  U[        U5      US9  g )N)r    )r   r   new_onessuper__init__r   )selfr   r   r   r   neg_one	__class__s         [/home/james-whalen/.local/lib/python3.13/site-packages/torch/distributions/inverse_gamma.pyr   InverseGamma.__init__.   sF     -]K	>>**2..~g.m 	 	
    c                 J   > U R                  [        U5      n[        TU ]  XS9$ )N)	_instance)_get_checked_instancer   r   expand)r   batch_shaper   newr   s       r   r   InverseGamma.expand:   s&    ((yAw~k~99r   c                 .    U R                   R                  $ N)r   r   r   s    r   r   InverseGamma.concentration>   s    ~~+++r   c                 .    U R                   R                  $ r#   )r   r   r$   s    r   r   InverseGamma.rateB   s    ~~"""r   c                     U R                   U R                  S-
  -  n[        R                  " U R                  S:  U[        R                  5      $ N   )r   r   torchwhereinfr   results     r   meanInverseGamma.meanF   s=    d00145{{4--16599EEr   c                 :    U R                   U R                  S-   -  $ r)   )r   r   r$   s    r   modeInverseGamma.modeK   s    yyD..233r   c                     U R                   R                  5       U R                  S-
  R                  5       U R                  S-
  -  -  n[        R                  " U R                  S:  U[        R
                  5      $ )Nr*      )r   squarer   r+   r,   r-   r.   s     r   varianceInverseGamma.varianceO   sd    !!#!#++-1C1Ca1GH
 {{4--16599EEr   c                     U R                   U R                  R                  5       -   U R                   R                  5       -   SU R                   -   U R                   R	                  5       -  -
  $ r)   )r   r   loglgammadigammar$   s    r   entropyInverseGamma.entropyV   sc    iimmo  '')* 4%%%););)C)C)EEF	
r   r   r#   )__name__
__module____qualname____firstlineno____doc__r   positivearg_constraintssupporthas_rsampler   __annotations__r   floatboolr   r   propertyr   r   r0   r3   r8   r>   __static_attributes____classcell__)r   s   @r   r   r      s   , %--$$O
 ""GK &*	

~

 un

 d{	


 


 

: ,v , , #f # # Ff F F 4f 4 4 F& F F
 
r   )r+   r   torch.distributionsr   torch.distributions.gammar   ,torch.distributions.transformed_distributionr   torch.distributions.transformsr   __all__r   r   r   r   <module>rT      s2      + + P 9 
N
* N
r   