a
    ‘º”h‡
  ã                   @   sr   d dl mZm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mZ dgZG d	d„ deƒZdS )
é    )ÚOptionalÚUnionN)ÚTensor)Úconstraints)ÚExponentialFamily)Úbroadcast_all)Ú_NumberÚ_sizeÚExponentialc                       sü   e Zd ZdZdejiZejZdZ	dZ
eedœdd„ƒZeedœdd	„ƒZeedœd
d„ƒZeedœdd„ƒZd#eeef ee ddœ‡ fdd„Zd$‡ fdd„	Ze ¡ feedœdd„Zdd„ Zdd„ Zdd„ Zdd„ Zeee dœdd „ƒZ d!d"„ Z!‡  Z"S )%r
   an  
    Creates a Exponential distribution parameterized by :attr:`rate`.

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterministic")
        >>> m = Exponential(torch.tensor([1.0]))
        >>> m.sample()  # Exponential distributed with rate=1
        tensor([ 0.1046])

    Args:
        rate (float or Tensor): rate = 1 / scale of the distribution
    ÚrateTr   )Úreturnc                 C   s
   | j  ¡ S ©N©r   Z
reciprocal©Úself© r   úM/var/www/auris/lib/python3.9/site-packages/torch/distributions/exponential.pyÚmean#   s    zExponential.meanc                 C   s   t  | j¡S r   )ÚtorchZ
zeros_liker   r   r   r   r   Úmode'   s    zExponential.modec                 C   s
   | j  ¡ S r   r   r   r   r   r   Ústddev+   s    zExponential.stddevc                 C   s   | j  d¡S )Néþÿÿÿ)r   Úpowr   r   r   r   Úvariance/   s    zExponential.varianceN)r   Úvalidate_argsr   c                    s<   t |ƒ\| _t|tƒrt ¡ n| j ¡ }tƒ j||d d S )N©r   )	r   r   Ú
isinstancer   r   ÚSizeÚsizeÚsuperÚ__init__)r   r   r   Úbatch_shape©Ú	__class__r   r   r    3   s    zExponential.__init__c                    sD   |   t|¡}t |¡}| j |¡|_tt|ƒj|dd | j|_|S )NFr   )	Z_get_checked_instancer
   r   r   r   Úexpandr   r    Ú_validate_args)r   r!   Z	_instanceÚnewr"   r   r   r$   <   s    
zExponential.expand)Úsample_shaper   c                 C   s    |   |¡}| j |¡ ¡ | j S r   )Z_extended_shaper   r&   Zexponential_)r   r'   Úshaper   r   r   ÚrsampleD   s    
zExponential.rsamplec                 C   s$   | j r|  |¡ | j ¡ | j|  S r   )r%   Ú_validate_sampler   Úlog©r   Úvaluer   r   r   Úlog_probH   s    
zExponential.log_probc                 C   s&   | j r|  |¡ dt | j | ¡ S )Né   )r%   r*   r   Úexpr   r,   r   r   r   ÚcdfM   s    
zExponential.cdfc                 C   s   t  | ¡ | j S r   )r   Úlog1pr   r,   r   r   r   ÚicdfR   s    zExponential.icdfc                 C   s   dt  | j¡ S )Ng      ð?)r   r+   r   r   r   r   r   ÚentropyU   s    zExponential.entropyc                 C   s
   | j  fS r   )r   r   r   r   r   Ú_natural_paramsX   s    zExponential._natural_paramsc                 C   s   t  | ¡ S r   )r   r+   )r   Úxr   r   r   Ú_log_normalizer\   s    zExponential._log_normalizer)N)N)#Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ZpositiveZarg_constraintsZnonnegativeZsupportZhas_rsampleZ_mean_carrier_measureÚpropertyr   r   r   r   r   r   Úfloatr   Úboolr    r$   r   r   r	   r)   r.   r1   r3   r4   Útupler5   r7   Ú__classcell__r   r   r"   r   r
      s8   
 ý
ü	)Útypingr   r   r   r   Ztorch.distributionsr   Ztorch.distributions.exp_familyr   Ztorch.distributions.utilsr   Ztorch.typesr   r	   Ú__all__r
   r   r   r   r   Ú<module>   s   