o
    Hh                     @   sV   d dl mZ 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 )	    )Tensor)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	efd
dZed	efddZed	efddZed	efddZed	ef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__ R/var/www/vscode/kcb/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.expandreturnc                 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	   0   r   zLogNormal.scalec                 C   s   | j | jdd   S N   )r   r	   powexpr   r   r   r   mean4   s   zLogNormal.meanc                 C   s   | j | j   S r   )r   r	   squarer    r   r   r   r   mode8   s   zLogNormal.modec                 C   s&   | j d}| d| j |   S r   )r	   r   expm1r   r    )r   scale_sqr   r   r   variance<   s   zLogNormal.variancec                 C   s   | j  | j S r   )r   entropyr   r   r   r   r   r'   A   s   zLogNormal.entropyr   )__name__
__module____qualname____doc__r   realpositivearg_constraintssupporthas_rsampler   r   propertyr   r   r	   r!   r#   r&   r'   __classcell__r   r   r   r   r      s$    N)torchr   torch.distributionsr   torch.distributions.normalr   ,torch.distributions.transformed_distributionr   torch.distributions.transformsr   __all__r   r   r   r   r   <module>   s   