o
    ‡ZŽ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__© úM/var/www/auris/lib/python3.10/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.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	   Zsquarer   r   r   r   r   Úmode8   s   zLogNormal.modec                 C   s&   | j  d¡}| ¡ d| j |  ¡  S r   )r	   r   Úexpm1r   r   )r   Z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   ÚrealZpositiveZarg_constraintsZsupportZhas_rsampler   r   Úpropertyr   r   r	   r   r    r"   r#   Ú__classcell__r   r   r   r   r      s$    N)Ztorchr   Ztorch.distributionsr   Ztorch.distributions.normalr   Z,torch.distributions.transformed_distributionr   Ztorch.distributions.transformsr   Ú__all__r   r   r   r   r   Ú<module>   s   