o
    h	                     @   s~   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 dl
mZmZ d dlmZ d dlmZ d	gZG d
d	 d	e	ZdS )    )Optional)Tensor)constraints)Exponential)TransformedDistribution)AffineTransformExpTransform)broadcast_all)_sizeParetoc                	       s   e Zd ZdZejejdZ	ddededee	 ddf fdd	Z
	dd
eded  dd f 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jddddejfddZdefddZ  ZS )r   a  
    Samples from a Pareto Type 1 distribution.

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterministic")
        >>> 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scaleNr   r   validate_argsreturnc                    sJ   t ||\| _| _t| j|d}t td| jdg}t j|||d d S )N)r   r   )locr   )r	   r   r   r   r   r   super__init__)selfr   r   r   	base_dist
transforms	__class__ n/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/torch/distributions/pareto.pyr   !   s   zPareto.__init__batch_shape	_instancec                    s8   |  t|}| j||_| j||_t j||dS )N)r   )_get_checked_instancer   r   expandr   r   )r   r   r   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   mean1   s   zPareto.meanc                 C   s   | j S N)r   r   r   r   r   mode7   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   variance;   s   &zPareto.varianceFr   )is_discrete	event_dimc                 C   s   t | jS r&   )r   greater_than_eqr   r'   r   r   r   supportA   s   zPareto.supportc                 C   s   | j | j  d| j   S )Nr   )r   r   log
reciprocalr'   r   r   r   entropyE   s   zPareto.entropyr&   )__name__
__module____qualname____doc__r   positivearg_constraintsr   r   boolr   r
   r   propertyr%   r(   r+   dependent_property
Constraintr/   r2   __classcell__r   r   r   r   r      s<    	N)typingr   torchr   torch.distributionsr   torch.distributions.exponentialr   ,torch.distributions.transformed_distributionr   torch.distributions.transformsr   r   torch.distributions.utilsr	   torch.typesr
   __all__r   r   r   r   r   <module>   s    