§
    Ÿ²ÅjË	  ã                   ót   — d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 dgZ G d„ de¦  «        ZdS )	é    N)Úinf)Úconstraints)ÚCauchy)ÚTransformedDistribution)ÚAbsTransformÚ
HalfCauchyc                   óÄ   ‡ — e Zd ZdZdej        iZej        ZdZ	dˆ fd„	Z
dˆ fd„	Zed„ ¦   «         Zed„ ¦   «         Zed	„ ¦   «         Zed
„ ¦   «         Zd„ Zd„ Zd„ Zd„ Zˆ xZS )r   a´  
    Creates a half-Cauchy distribution parameterized by `scale` where::

        X ~ Cauchy(0, scale)
        Y = |X| ~ HalfCauchy(scale)

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterministic")
        >>> m = HalfCauchy(torch.tensor([1.0]))
        >>> m.sample()  # half-cauchy distributed with scale=1
        tensor([ 2.3214])

    Args:
        scale (float or Tensor): scale of the full Cauchy distribution
    ÚscaleTNc                 óŒ   •— t          d|d¬¦  «        }t          ¦   «                              |t          ¦   «         |¬¦  «         d S )Nr   F)Úvalidate_args)r   ÚsuperÚ__init__r   )Úselfr
   r   Ú	base_distÚ	__class__s       €úPC:\Projects\Historical\venv\Lib\site-packages\torch/distributions/half_cauchy.pyr   zHalfCauchy.__init__$   s@   ø€ Ý˜1˜e°5Ð9Ñ9Ô9ˆ	Ý‰Œ×Ò˜¥L¡N¤NÀ-ÐÑPÔPÐPÐPÐPó    c                 ó€   •— |                       t          |¦  «        }t          ¦   «                              ||¬¦  «        S )N)Ú	_instance)Ú_get_checked_instancer   r   Úexpand)r   Úbatch_shaper   Únewr   s       €r   r   zHalfCauchy.expand(   s2   ø€ Ø×(Ò(­°YÑ?Ô?ˆÝ‰wŒw�~Š~˜k°Sˆ~Ñ9Ô9Ð9r   c                 ó   — | j         j        S ©N)r   r
   ©r   s    r   r
   zHalfCauchy.scale,   s   € àŒ~Ô#Ð#r   c                 ó’   — t          j        |                      ¦   «         t          j        | j        j        | j        j        ¬¦  «        S )N©ÚdtypeÚdevice)ÚtorchÚfullÚ_extended_shapeÚmathr   r
   r   r    r   s    r   ÚmeanzHalfCauchy.mean0   s?   € åŒzØ× Ò Ñ"Ô"ÝŒHØ”*Ô"Ø”:Ô$ð	
ñ 
ô 
ð 	
r   c                 ó4   — t          j        | j        ¦  «        S r   )r!   Ú
zeros_liker
   r   s    r   ÚmodezHalfCauchy.mode9   s   € åÔ ¤
Ñ+Ô+Ð+r   c                 ó   — | j         j        S r   )r   Úvariancer   s    r   r*   zHalfCauchy.variance=   s   € àŒ~Ô&Ð&r   c                 óF  — | j         r|                      |¦  «         t          j        || j        j        j        | j        j        j        ¬¦  «        }| j                             |¦  «        t          j
        d¦  «        z   }t          j        |dk    |t           ¦  «        }|S )Nr   é   r   )Ú_validate_argsÚ_validate_sampler!   Ú	as_tensorr   r
   r   r    Úlog_probr$   ÚlogÚwherer   )r   Úvaluer0   s      r   r0   zHalfCauchy.log_probA   s�   € ØÔð 	)Ø×!Ò! %Ñ(Ô(Ð(Ý”Ø˜œÔ-Ô3¸D¼NÔ<PÔ<Wð
ñ 
ô 
ˆð ”>×*Ò*¨5Ñ1Ô1µD´H¸Q±K´KÑ?ˆÝ”;˜u¨šz¨8µc°TÑ:Ô:ˆØˆr   c                 óz   — | j         r|                      |¦  «         d| j                             |¦  «        z  dz
  S )Nr,   é   )r-   r.   r   Úcdf)r   r3   s     r   r6   zHalfCauchy.cdfK   sA   € ØÔð 	)Ø×!Ò! %Ñ(Ô(Ð(Ø�4”>×%Ò% eÑ,Ô,Ñ,¨qÑ0Ð0r   c                 óB   — | j                              |dz   dz  ¦  «        S )Nr5   r,   )r   Úicdf)r   Úprobs     r   r8   zHalfCauchy.icdfP   s    € ØŒ~×"Ò" D¨1¡H°¡>Ñ2Ô2Ð2r   c                 ó^   — | j                              ¦   «         t          j        d¦  «        z
  S )Nr,   )r   Úentropyr$   r1   r   s    r   r;   zHalfCauchy.entropyS   s#   € ØŒ~×%Ò%Ñ'Ô'­$¬(°1©+¬+Ñ5Ð5r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚpositiveÚarg_constraintsÚnonnegativeÚsupportÚhas_rsampler   r   Úpropertyr
   r%   r(   r*   r0   r6   r8   r;   Ú__classcell__)r   s   @r   r   r      s/  ø€ € € € € ðð ð   Ô 4Ð5€OØÔ%€GØ€KðQð Qð Qð Qð Qð Qð:ð :ð :ð :ð :ð :ð ð$ð $ñ „Xð$ð ð
ð 
ñ „Xð
ð ð,ð ,ñ „Xð,ð ð'ð 'ñ „Xð'ðð ð ð1ð 1ð 1ð
3ð 3ð 3ð6ð 6ð 6ð 6ð 6ð 6ð 6r   )r$   r!   r   Útorch.distributionsr   Útorch.distributions.cauchyr   Ú,torch.distributions.transformed_distributionr   Útorch.distributions.transformsr   Ú__all__r   © r   r   ú<module>rM      s¹   ðà €€€à €€€Ø Ð Ð Ð Ð Ð Ø +Ð +Ð +Ð +Ð +Ð +Ø -Ð -Ð -Ð -Ð -Ð -Ø PÐ PÐ PÐ PÐ PÐ PØ 7Ð 7Ð 7Ð 7Ð 7Ð 7ð ˆ.€ðE6ð E6ð E6ð E6ð E6Ð(ñ E6ô E6ð E6ð E6ð E6r   