U
    Jc                     @   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)ExpTransform)Normal)TransformedDistribution	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t| j|t |d d S )N)validate_args)r   superr   __init__r   )selfr   r   r	   	base_dist	__class__ B/tmp/pip-unpacked-wheel-gikjz4vx/torch/distributions/log_normal.pyr      s    zLogNormal.__init__c                    s    |  t|}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   mean/   s    zLogNormal.meanc                 C   s   | j | j   S r   )r   r   Zsquarer   r   r   r   r   mode3   s    zLogNormal.modec                 C   s.   | j d d d| j | j d   S )Nr      )r   r   r   r   r   r   r   r   variance7   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.transformsr   Ztorch.distributions.normalr   Z,torch.distributions.transformed_distributionr   __all__r   r   r   r   r   <module>   s
   