o
    h	                     @   sR   d dl mZ d dlZd dlmZ d dlmZ d dlmZ dgZ	G dd deZ
dS )    )NumberN)constraints)ExponentialFamily)broadcast_allExponentialc                       s   e Zd ZdZdejiZejZdZ	dZ
edd Zedd Zed	d
 Zedd Zd  fdd	Zd  fdd	Ze fddZdd Zdd Zdd Zdd Zedd Zdd Z  ZS )!r   am  
    Creates a Exponential distribution parameterized by :attr:`rate`.

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterinistic")
        >>> 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   c                 C   
   | j  S Nr   
reciprocalself r   U/var/www/html/ai/venv/lib/python3.10/site-packages/torch/distributions/exponential.pymean      
zExponential.meanc                 C   s   t | jS r	   )torch
zeros_liker   r   r   r   r   mode"      zExponential.modec                 C   r   r	   r
   r   r   r   r   stddev&   r   zExponential.stddevc                 C   s   | j dS )N)r   powr   r   r   r   variance*   r   zExponential.varianceNc                    s<   t |\| _t|trt n| j }t j||d d S )Nvalidate_args)	r   r   
isinstancer   r   Sizesizesuper__init__)r   r   r   batch_shape	__class__r   r   r    .   s   zExponential.__init__c                    sD   |  t|}t|}| j||_tt|j|dd | j|_|S )NFr   )	_get_checked_instancer   r   r   r   expandr   r    _validate_args)r   r!   	_instancenewr"   r   r   r%   3   s   
zExponential.expandc                 C   s    |  |}| j| | j S r	   )_extended_shaper   r(   exponential_)r   sample_shapeshaper   r   r   rsample;   s   
zExponential.rsamplec                 C   s$   | j r| | | j | j|  S r	   )r&   _validate_sampler   logr   valuer   r   r   log_prob?   s   
zExponential.log_probc                 C   s&   | j r| | dt| j |  S )N   )r&   r.   r   expr   r0   r   r   r   cdfD   s   
zExponential.cdfc                 C   s   t |  | j S r	   )r   log1pr   r0   r   r   r   icdfI   s   zExponential.icdfc                 C   s   dt | j S )Ng      ?)r   r/   r   r   r   r   r   entropyL   s   zExponential.entropyc                 C   s
   | j  fS r	   )r   r   r   r   r   _natural_paramsO   r   zExponential._natural_paramsc                 C   s   t |  S r	   )r   r/   )r   xr   r   r   _log_normalizerS   s   zExponential._log_normalizerr	   )__name__
__module____qualname____doc__r   positivearg_constraintsnonnegativesupporthas_rsample_mean_carrier_measurepropertyr   r   r   r   r    r%   r   r   r-   r2   r5   r7   r8   r9   r;   __classcell__r   r   r"   r   r      s0    





)numbersr   r   torch.distributionsr   torch.distributions.exp_familyr   torch.distributions.utilsr   __all__r   r   r   r   r   <module>   s    