
    'YHhX                     :    d Z ddlZddlmZ ddZ G d de      Zy)	zc Extreme Value Copulas
Created on Fri Jan 29 19:19:45 2021

Author: Josef Perktold
License: BSD-3

    N   )Copulac           
          | \  } }t        j                  t        j                  | |z         |t        j                  |       t        j                  | |z        z  g| z        S )z+generic bivariate extreme value copula
    )npexplog)u	transformargsvs       g/var/www/html/planif/env/lib/python3.12/site-packages/statsmodels/distributions/copula/extreme_value.pycopula_bv_evr      sP     DAq66"&&Q-9RVVAYrvvac{-B#JT#JK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

    c                     t         |   |       || _        |j                  | _        || _        |dk7  rt        d      y )N)k_dim   z(Only bivariate EV copulas are available.)super__init__r
   k_argsr   
ValueError)selfr
   r   r   	__class__s       r   r   zExtremeValueCopula.__init__5   sF    u%"&&	A:GHH r   c                     t        |t        j                        rt        |      }|dk(  s|| j                  }t        |t              s|f}|S )N )
isinstancer   ndarraytupler   )r   r   s     r   _handle_argszExtremeValueCopula._handle_args=   sE     dBJJ';D2:99D$&7Dr   c           
      B   t        j                  |      j                  \  }}| j                  |      }t        j                  t        j
                  ||z         | j                  t        j
                  |      t        j
                  ||z        z  g| 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}    & zz!}1  &vvbffQUm$dnnRVVAYrvvac{%:BTBC Dr   c                    | j                   }t        j                  |      j                  \  }}| j	                  |      }t        j
                  ||z        }t        j
                  |      |z  }| j                  ||      } ||g| }	 |j                  |g| }
 |j                  |g| }|||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/FF2J hhq$lTlRXXa$RYYq 4 b2g3!a%2#5#B,"G"$A,"2W"<#= > r   c                 N    t        j                  | 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     $ vvdhhqth,--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
2B.(	""r   r   r=   )rA   numpyr   copulasr   r   r   r   r   r   <module>rE      s&     MO" O"r   