
    M/PhX                     B    d Z ddlZddlmZ d	dZ G d de          ZdS )
zc Extreme Value Copulas
Created on Fri Jan 29 19:19:45 2021

Author: Josef Perktold
License: BSD-3

    N   )Copula c           
          | \  } }t          j        t          j        | |z             |t          j        |           t          j        | |z            z  g|R  z            S )z+generic bivariate extreme value copula
    )npexplog)u	transformargsvs       n/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/distributions/copula/extreme_value.pycopula_bv_evr      sY     DAq6"&Q--99RVAYYrvac{{-B#JT#J#J#JKLLL    c                   P     e Zd ZdZd fd	Zd ZddZddZddZdd	Z	d
 Z
 xZS )ExtremeValueCopulaaS  Extreme value copula constructed from Pickand's dependence function.

    Currently only bivariate copulas are available.

    Parameters
    ----------
    transform: instance of transformation class
        Pickand's dependence function with required methods including first
        and second derivatives
    args : tuple
        Optional copula parameters. Copula parameters can be either provided
        when creating the instance or as arguments when calling methods.
    k_dim : int
        Currently only bivariate extreme value copulas are supported.

    Notes
    -----
    currently the following dependence function and copulas are available

    - AsymLogistic
    - AsymNegLogistic
    - AsymMixed
    - HR

    TEV and AsymBiLogistic currently do not have required derivatives for pdf.

    See Also
    --------
    dep_func_ev

    r      c                     t                                          |           || _        |j        | _        || _        |dk    rt          d          d S )N)k_dimr   z(Only bivariate EV copulas are available.)super__init__r   k_argsr   
ValueError)selfr   r   r   	__class__s       r   r   zExtremeValueCopula.__init__5   sU    u%%%"&	A::GHHH :r   c                     t          |t          j                  rt          |          }|dk    s|| j        }t          |t                    s|f}|S )Nr   )
isinstancer   ndarraytupler   )r   r   s     r   _handle_argszExtremeValueCopula._handle_args=   sU     dBJ'' 	;;D2::9D$&& 	7Dr   c           
      ,   t          j        |          j        \  }}|                     |          }t          j        t          j        ||z             | j        t          j        |          t          j        ||z            z  g|R  z            }|S )aJ  Evaluate cdf of bivariate extreme value copula.

        Parameters
        ----------
        u : array_like
            Values of random bivariate random variable, each defined on [0, 1],
            for which cdf is computed.
            Can be two dimensional with multivariate components in columns and
            observation in rows.
        args : tuple
            Required parameters for the copula. The meaning and number of
            parameters in the tuple depends on the specific copula.

        Returns
        -------
        CDF values at evaluation points.
        )r   asarrayTr    r   r	   r   )r   r
   r   r   cdfvs        r   cdfzExtremeValueCopula.cdfI   s    & z!}}1  &&vbfQUmm$dnRVAYYrvac{{%:BTBBBC D Dr   c                    | j         }t          j        |          j        \  }}|                     |          }t          j        ||z            }t          j        |          |z  }|                     ||          } ||g|R  }	 |j        |g|R  }
 |j        |g|R  }|||z  z  |	d|z
  |
z  z   |	||
z  z
  z  |d|z
  z  |z  |z  z
  z  }|S )aJ  Evaluate pdf of bivariate extreme value copula.

        Parameters
        ----------
        u : array_like
            Values of random bivariate random variable, each defined on [0, 1],
            for which cdf is computed.
            Can be two dimensional with multivariate components in columns and
            observation in rows.
        args : tuple
            Required parameters for the copula. The meaning and number of
            parameters in the tuple depends on the specific copula.

        Returns
        -------
        PDF values at evaluation points.
        r   )	r   r   r"   r#   r    r	   r%   derivderiv2)r   r
   r   tru1u2log_u12tr%   depd1d2pdf_s                r   pdfzExtremeValueCopula.pdfb   s    $ ^AB  &&&b//F2JJ hhq$blTlllRXa$RYq 4   b2g3!a%2#5#B,"G"$A,"2W"<#= > r   c                 T    t          j        |                     ||                    S )aR  Evaluate log-pdf of bivariate extreme value copula.

        Parameters
        ----------
        u : array_like
            Values of random bivariate random variable, each defined on [0, 1],
            for which cdf is computed.
            Can be two dimensional with multivariate components in columns and
            observation in rows.
        args : tuple
            Required parameters for the copula. The meaning and number of
            parameters in the tuple depends on the specific copula.

        Returns
        -------
        Log-pdf values at evaluation points.
        )r   )r   r	   r2   r   r
   r   s      r   logpdfzExtremeValueCopula.logpdf   s$    $ vdhhqth,,---r   c                     t           )u   conditional distribution

        not yet implemented

        C2|1(u2|u1) := ∂C(u1, u2) / ∂u1 = C(u1, u2) / u1 * (A(t) − t A'(t))

        where t = np.log(v)/np.log(u*v)
        NotImplementedErrorr4   s      r   conditional_2g1z"ExtremeValueCopula.conditional_2g1   s
     "!r   c                     t           )Nr7   )r   datas     r   fit_corr_paramz!ExtremeValueCopula.fit_corr_param   s    !!r   )r   r   r   )__name__
__module____qualname____doc__r   r    r%   r2   r5   r9   r<   __classcell__)r   s   @r   r   r      s         @I I I I I I
 
 
   2   B. . . .(	" 	" 	" 	"" " " " " " "r   r   r=   )rA   numpyr   copulasr   r   r   r   r   r   <module>rE      s              M M M MO" O" O" O" O" O" O" O" O" O"r   