U
    dE                     @   sD   d dl mZ d dlmZ d dlmZ d dlmZ G dd deZdS )    )constraints)ExpTransform)Normal)TransformedDistributionc                       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 )	LogNormala  
    Creates a log-normal distribution parameterized by
    :attr:`loc` and :attr:`scale` where::

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

    Example::

        >>> 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-ua33x9lu/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   mode1   s    zLogNormal.modec                 C   s.   | j d d d| j | j d   S )Nr      )r   r   r   r   r   r   r   r   variance5   s    zLogNormal.variancec                 C   s   | j  | j S r   )r   entropyr   r   r   r   r   r   9   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"   




r   N)	Ztorch.distributionsr   Ztorch.distributions.transformsr   Ztorch.distributions.normalr   Z,torch.distributions.transformed_distributionr   r   r   r   r   r   <module>   s   