U
    yâ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   a8  
    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-deterministic")
        >>> 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__© úP/var/www/html/venv/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   Úmean1   s    zLogNormal.meanc                 C   s   | j | j ¡   ¡ S r   )r   r   Zsquarer   r   r   r   r   Úmode5   s    zLogNormal.modec                 C   s&   | j  d¡}| ¡ d| j |  ¡  S r   )r   r   Úexpm1r   r   )r   Zscale_sqr   r   r   Úvariance9   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
   