U
    ©Ê¹j~  ã                   @   sZ   d dl mZ d dlmZ d dlmZ d dlmZmZ d dl	m
Z
 dgZG dd„ deƒZdS )	é    )Úconstraints)ÚExponential)ÚTransformedDistribution)ÚAffineTransformÚExpTransform)Úbroadcast_allÚParetoc                       s€   e Zd ZdZejej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jddd�dd„ ƒZdd„ Z‡  ZS )r   aÂ  
    Samples from a Pareto Type 1 distribution.

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterinistic")
        >>> m = Pareto(torch.tensor([1.0]), torch.tensor([1.0]))
        >>> m.sample()  # sample from a Pareto distribution with scale=1 and alpha=1
        tensor([ 1.5623])

    Args:
        scale (float or Tensor): Scale parameter of the distribution
        alpha (float or Tensor): Shape parameter of the distribution
    )ÚalphaÚscaleNc                    sJ   t ||ƒ\| _| _t| j|d�}tƒ td| jd�g}tƒ j|||d� d S )N)Úvalidate_argsr   )Úlocr
   )r   r
   r	   r   r   r   ÚsuperÚ__init__)Úselfr
   r	   r   Z	base_distZ
transforms©Ú	__class__© úY/var/www/html/bwave/python/venv/lib/python3.8/site-packages/torch/distributions/pareto.pyr      s    zPareto.__init__c                    s8   |   t|¡}| j |¡|_| j |¡|_tƒ j||d�S )N)Ú	_instance)Z_get_checked_instancer   r
   Úexpandr	   r   )r   Zbatch_shaper   Únewr   r   r   r   !   s    zPareto.expandc                 C   s    | j jdd�}|| j |d  S )Né   ©Úmin)r	   Úclampr
   ©r   Úar   r   r   Úmean'   s    zPareto.meanc                 C   s   | j S ©N)r
   ©r   r   r   r   Úmode-   s    zPareto.modec                 C   s4   | j jdd�}| j d¡| |d  d¡|d   S )Né   r   r   )r	   r   r
   Úpowr   r   r   r   Úvariance1   s    zPareto.varianceFr   )Zis_discreteZ	event_dimc                 C   s   t  | j¡S r   )r   Zgreater_than_eqr
   r   r   r   r   Úsupport7   s    zPareto.supportc                 C   s   | j | j  ¡ d| j ¡   S )Nr   )r
   r	   ÚlogZ
reciprocalr   r   r   r   Úentropy;   s    zPareto.entropy)N)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ZpositiveZarg_constraintsr   r   Úpropertyr   r    r#   Zdependent_propertyr$   r&   Ú__classcell__r   r   r   r   r   
   s   



N)Ztorch.distributionsr   Ztorch.distributions.exponentialr   Z,torch.distributions.transformed_distributionr   Ztorch.distributions.transformsr   r   Ztorch.distributions.utilsr   Ú__all__r   r   r   r   r   Ú<module>   s   