o
    h                     @   s~   d dl Z d dl mZ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mZ dgZd	d
 ZG dd deZdS )    N)nanTensor)constraints)TransformedDistribution)AffineTransformPowerTransform)Uniform)broadcast_alleuler_constantKumaraswamyc                 C   s<   d||   }t |t | t ||  }|t | S )zE
    Computes nth moment of Kumaraswamy using using torch.lgamma
       )torchlgammaexp)abnarg1	log_value r   s/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/torch/distributions/kumaraswamy.py_moments   s   "r   c                       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dd Z  ZS )r   aS  
    Samples from a Kumaraswamy distribution.

    Example::

        >>> # xdoctest: +IGNORE_WANT("non-deterministic")
        >>> m = Kumaraswamy(torch.tensor([1.0]), torch.tensor([1.0]))
        >>> m.sample()  # sample from a Kumaraswamy distribution with concentration alpha=1 and beta=1
        tensor([ 0.1729])

    Args:
        concentration1 (float or Tensor): 1st concentration parameter of the distribution
            (often referred to as alpha)
        concentration0 (float or Tensor): 2nd concentration parameter of the distribution
            (often referred to as beta)
    )concentration1concentration0TNc                    st   t ||\| _| _tt| jdt| jd|d}t| j dtdddt| j dg}t	 j
|||d d S )Nr   r   )validate_args)exponentg      ?g      )locscale)r	   r   r   r   r   	full_liker   
reciprocalr   super__init__)selfr   r   r   	base_dist
transforms	__class__r   r   r!   0   s   
zKumaraswamy.__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Kumaraswamy.expandreturnc                 C   s   t | j| jdS Nr   )r   r   r   r"   r   r   r   meanF   s   zKumaraswamy.meanc                 C   sH   | j  | j    | j  | j   }t|| j dk | jdk B < | S r-   )r   r   log1pr   r   r   )r"   log_moder   r   r   modeJ   s   zKumaraswamy.modec                 C   s   t | j| jdt| jd S )N   )r   r   r   r   powr/   r.   r   r   r   varianceT   s   zKumaraswamy.variancec                 C   sT   d| j   }d| j  }t| jd t }|||  t| j  t| j S r-   )r   r   r   r   digammar
   log)r"   t1t0H0r   r   r   entropyZ   s   

zKumaraswamy.entropy)N)__name__
__module____qualname____doc__r   positivearg_constraintsunit_intervalsupporthas_rsampler!   r)   propertyr   r/   r2   r5   r;   __classcell__r   r   r%   r   r      s     	)r   r   r   torch.distributionsr   ,torch.distributions.transformed_distributionr   torch.distributions.transformsr   r   torch.distributions.uniformr   torch.distributions.utilsr	   r
   __all__r   r   r   r   r   r   <module>   s   	