o
    /ôjÂ  ã                   @   sz   d dl 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mZ dgZd	d
„ ZG dd„ deƒZdS )é    N)Únan)Ú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Úarg1Z	log_value© r   úp/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/torch/distributions/kumaraswamy.pyÚ_moments   s   "r   c                       st   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	d
„ ƒZedd„ ƒZe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                    s‚   t ||ƒ\| _| _t | jj¡}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   ÚfinfoÚdtyper   Ú	full_liker   Ú
reciprocalr   ÚsuperÚ__init__)Úselfr   r   r   r   Ú	base_distÚ
transforms©Ú	__class__r   r   r!   .   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.expandc                 C   s   t | j| jdƒS ©Nr   )r   r   r   ©r"   r   r   r   ÚmeanE   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"   Zlog_moder   r   r   ÚmodeI   s   ÿÿzKumaraswamy.modec                 C   s   t | j| jdƒt | jd¡ S )Né   )r   r   r   r   Úpowr.   r-   r   r   r   ÚvarianceS   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Út0ZH0r   r   r   ÚentropyY   s   ÿ
þ
ýÿzKumaraswamy.entropy)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚpositiveÚarg_constraintsÚunit_intervalÚsupportÚhas_rsampler!   r)   Úpropertyr.   r0   r3   r8   Ú__classcell__r   r   r%   r   r
      s     þ

	
)r   r   Ztorch.distributionsr   Ú,torch.distributions.transformed_distributionr   Ztorch.distributions.transformsr   r   Útorch.distributions.uniformr   Útorch.distributions.utilsr   r	   Ú__all__r   r
   r   r   r   r   Ú<module>   s   	