o
    h                     @   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__ T/var/www/html/ai/venv/lib/python3.10/site-packages/torch/distributions/log_normal.pyr       s   zLogNormal.__init__c                    s   |  t|}t j||dS )N)	_instance)_get_checked_instancer   r
   expand)r   batch_shaper   newr   r   r   r   $   s   zLogNormal.expandc                 C      | j jS N)r   r   r   r   r   r   r   (      zLogNormal.locc                 C   r   r   )r   r   r   r   r   r   r   ,   r   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   squarer   r   r   r   r   mode4   s   zLogNormal.modec                 C   s&   | j d}| d| j |   S r   )r   r   expm1r   r   )r   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.entropyr   )__name__
__module____qualname____doc__r   realpositivearg_constraintssupporthas_rsampler   r   propertyr   r   r   r!   r$   r%   __classcell__r   r   r   r   r   	   s$    




N)
torch.distributionsr   torch.distributions.normalr   ,torch.distributions.transformed_distributionr   torch.distributions.transformsr   __all__r   r   r   r   r   <module>   s    