o
    h~                     @   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   	base_dist
transforms	__class__ P/var/www/html/ai/venv/lib/python3.10/site-packages/torch/distributions/pareto.pyr      s   zPareto.__init__c                    s8   |  t|}| j||_| j||_t j||dS )N)	_instance)_get_checked_instancer   r
   expandr	   r   )r   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   )is_discrete	event_dimc                 C   s   t | jS r"   )r   greater_than_eqr
   r#   r   r   r   support7   s   zPareto.supportc                 C   s   | j | j  d| j   S )Nr   )r
   r	   log
reciprocalr#   r   r   r   entropy;   s   zPareto.entropyr"   )__name__
__module____qualname____doc__r   positivearg_constraintsr   r   propertyr!   r$   r'   dependent_propertyr+   r.   __classcell__r   r   r   r   r   
   s    



N)torch.distributionsr   torch.distributions.exponentialr   ,torch.distributions.transformed_distributionr   torch.distributions.transformsr   r   torch.distributions.utilsr   __all__r   r   r   r   r   <module>   s    