
    }Yhd                         d dl Z d dlmZmZ d dlZd dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZmZ dgZ G d	 de          ZdS )
    N)OptionalUnion)infnanTensor)constraints)Distribution)broadcast_all)_Number_sizeCauchyc            	       :    e Zd ZdZej        ej        dZej        ZdZ		 dde
eef         de
eef         dee         ddf fd	Zd fd
	Zedefd            Zedefd            Zedefd            Z ej                    fdedefdZd Zd Zd Zd Z xZS )r   aC  
    Samples from a Cauchy (Lorentz) distribution. The distribution of the ratio of
    independent normally distributed random variables with means `0` follows a
    Cauchy distribution.

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterministic")
        >>> m = Cauchy(torch.tensor([0.0]), torch.tensor([1.0]))
        >>> m.sample()  # sample from a Cauchy distribution with loc=0 and scale=1
        tensor([ 2.3214])

    Args:
        loc (float or Tensor): mode or median of the distribution.
        scale (float or Tensor): half width at half maximum.
    )locscaleTNr   r   validate_argsreturnc                 6   t          ||          \  | _        | _        t          |t                    r)t          |t                    rt          j                    }n| j                                        }t                      	                    ||           d S )Nr   )
r
   r   r   
isinstancer   torchSizesizesuper__init__)selfr   r   r   batch_shape	__class__s        l/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/torch/distributions/cauchy.pyr   zCauchy.__init__&   s      -S%88$*c7## 	*
5'(B(B 	**,,KK(--//KMBBBBB    c                 N   |                      t          |          }t          j        |          }| j                            |          |_        | j                            |          |_        t          t          |                              |d           | j	        |_	        |S )NFr   )
_get_checked_instancer   r   r   r   expandr   r   r   _validate_args)r   r   	_instancenewr   s       r   r"   zCauchy.expand3   s    ((;;j--(//+..J%%k22	fc##Ku#EEE!0
r   c                     t          j        |                                 t          | j        j        | j        j                  S N)dtypedevice)r   full_extended_shaper   r   r(   r)   r   s    r   meanzCauchy.mean<   8    z  ""Ctx~dho
 
 
 	
r   c                     | j         S N)r   r,   s    r   modezCauchy.modeB   s	    xr   c                     t          j        |                                 t          | j        j        | j        j                  S r'   )r   r*   r+   r   r   r(   r)   r,   s    r   variancezCauchy.varianceF   r.   r   sample_shapec                     |                      |          }| j                            |                                          }| j        || j        z  z   S r0   )r+   r   r%   cauchy_r   )r   r4   shapeepss       r   rsamplezCauchy.rsampleL   sH    $$\22hll5!!))++x#
***r   c                     | j         r|                     |           t          j        t          j                   | j                                        z
  || j        z
  | j        z  dz                                  z
  S )N   )r#   _validate_samplemathlogpir   r   log1pr   values     r   log_probzCauchy.log_probQ   ss     	)!!%(((Xdgjnn!TZ/A5<<>>?	
r   c                     | j         r|                     |           t          j        || j        z
  | j        z            t          j        z  dz   S Ng      ?)r#   r<   r   atanr   r   r=   r?   rA   s     r   cdfz
Cauchy.cdfZ   sK     	)!!%(((z548+tz9::TWDsJJr   c                 j    t          j        t          j        |dz
  z            | j        z  | j        z   S rE   )r   tanr=   r?   r   r   rA   s     r   icdfzCauchy.icdf_   s+    yECK011DJ>IIr   c                 x    t          j        dt           j        z            | j                                        z   S )N   )r=   r>   r?   r   r,   s    r   entropyzCauchy.entropyb   s)    xDG$$tz~~'7'777r   r0   )__name__
__module____qualname____doc__r   realpositivearg_constraintssupporthas_rsampler   r   floatr   boolr   r"   propertyr-   r1   r3   r   r   r   r9   rC   rG   rJ   rM   __classcell__)r   s   @r   r   r      s        " *.9MNNOGK )-	C C65=!C VU]#C  ~	C
 
C C C C C C      
f 
 
 
 X

 f    X 
& 
 
 
 X

 -7EJLL + +E +V + + + +

 
 
K K K
J J J8 8 8 8 8 8 8r   )r=   typingr   r   r   r   r   r   torch.distributionsr    torch.distributions.distributionr	   torch.distributions.utilsr
   torch.typesr   r   __all__r    r   r   <module>rb      s     " " " " " " " "  " " " " " " " " " " + + + + + + 9 9 9 9 9 9 3 3 3 3 3 3 & & & & & & & & *S8 S8 S8 S8 S8\ S8 S8 S8 S8 S8r   