U
    9%e                     @   sJ   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 deZ	dS )    )constraints)Normal)TransformedDistribution)ExpTransform	LogNormalc                       s   e Zd ZdZejejdZejZdZ	d fdd	Z
d fdd	Zed	d
 Zedd Zedd Zedd Zedd Zdd Z  ZS )r   a7  
    Creates a log-normal distribution parameterized by
    :attr:`loc` and :attr:`scale` where::

        X ~ Normal(loc, scale)
        Y = exp(X) ~ LogNormal(loc, scale)

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterinistic")
        >>> m = LogNormal(torch.tensor([0.0]), torch.tensor([1.0]))
        >>> m.sample()  # log-normal distributed with mean=0 and stddev=1
        tensor([ 0.1046])

    Args:
        loc (float or Tensor): mean of log of distribution
        scale (float or Tensor): standard deviation of log of the distribution
    )locscaleTNc                    s&   t |||d}t j|t |d d S )N)validate_args)r   super__init__r   )selfr   r   r	   	base_dist	__class__ ]/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/torch/distributions/log_normal.pyr       s    zLogNormal.__init__c                    s   |  t|}t j||dS )N)	_instance)Z_get_checked_instancer   r
   expand)r   Zbatch_shaper   newr   r   r   r   $   s    zLogNormal.expandc                 C   s   | j jS N)r   r   r   r   r   r   r   (   s    zLogNormal.locc                 C   s   | j jS r   )r   r   r   r   r   r   r   ,   s    zLogNormal.scalec                 C   s   | j | jdd   S N   )r   r   powexpr   r   r   r   mean0   s    zLogNormal.meanc                 C   s   | j | j   S r   )r   r   Zsquarer   r   r   r   r   mode4   s    zLogNormal.modec                 C   s&   | j d}| d| j |   S r   )r   r   expm1r   r   )r   Zscale_sqr   r   r   variance8   s    zLogNormal.variancec                 C   s   | j  | j S r   )r   entropyr   r   r   r   r   r   =   s    zLogNormal.entropy)N)N)__name__
__module____qualname____doc__r   realZpositiveZarg_constraintsZsupportZhas_rsampler   r   propertyr   r   r   r   r   r   __classcell__r   r   r   r   r   	   s"   




N)
Ztorch.distributionsr   Ztorch.distributions.normalr   Z,torch.distributions.transformed_distributionr   Ztorch.distributions.transformsr   __all__r   r   r   r   r   <module>   s
   