
    M/Ph                     f    d Z ddlZddlmZ ddlmZ ddlmZ  G d de          Z	dd
Z
d Zd ZdS )zM
Created on Fri Jan 29 19:19:45 2021

Author: Josef Perktold
License: BSD-3

    N)stats)check_random_state)Copulac                   N     e Zd ZdZd fd	Zd ZddZdd	Zdd
Zd Z	d Z
 xZS )IndependenceCopulaa  Independence copula.

    Copula with independent random variables.

    .. math::

        C_	heta(u,v) = uv

    Parameters
    ----------
    k_dim : int
        Dimension, number of components in the multivariate random variable.

    Notes
    -----
    IndependenceCopula does not have copula parameters.
    If non-empty ``args`` are provided in methods, then a ValueError is raised.
    The ``args`` keyword is provided for a consistent interface across
    copulas.

       c                 L    t                                          |           d S )N)k_dim)super__init__)selfr
   	__class__s     n/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/distributions/copula/other_copulas.pyr   zIndependenceCopula.__init__%   s$    u%%%%%    c                 8    |dk    r|d}t          |          |S )N z3Independence copula does not use copula parameters.)
ValueError)r   argsmsgs      r   _handle_argszIndependenceCopula._handle_args(   s&    2::$*HCS//!Kr      r   Nc                     |                      |           t          |          }|                    || j        f          }|S )N)r   r   randomr
   )r   nobsr   random_staterngxs         r   rvszIndependenceCopula.rvs/   s@    $ ..JJdj)**r   c                 l    t          j        |          }t          j        |j        d d                   S )N)npasarrayonesshaper   ur   s      r   pdfzIndependenceCopula.pdf5   s)    JqMMwqwss|$$$r   c                 .    t          j        |d          S )Nr    )axis)r!   prodr%   s      r   cdfzIndependenceCopula.cdf9   s    wqr""""r   c                     dS )Nr   r   )r   s    r   tauzIndependenceCopula.tau<   s    qr   c                      t          d          )Nz PDF is constant over the domain.)NotImplementedError)r   r   s     r   plot_pdfzIndependenceCopula.plot_pdf?   s    !"DEEEr   )r   )r   r   N)r   )__name__
__module____qualname____doc__r   r   r   r'   r+   r-   r0   __classcell__)r   s   @r   r   r      s         *& & & & & &     % % % %# # # #  F F F F F F Fr   r   r   Fc                    	 | j         d         }|t          	t          j                            d||          }| |         }t          j        	fd|j        D                       }|r|||fS |S )a  Random sampling from empirical copula using Beta distribution

    Parameters
    ----------
    sample : ndarray
        Sample of multivariate observations in (o, 1) interval.
    size : int
        Number of observations to simulate.
    bw : float
        Bandwidth for Beta sampling. The beta copula corresponds to a kernel
        estimate of the distribution. bw=1 corresponds to the empirical beta
        copula. A small bandwidth like bw=0.001 corresponds to small noise
        added to the empirical distribution. Larger bw, e.g. bw=10 corresponds
        to kernel estimate with more smoothing.
    k_func : None or callable
        The default kernel function is currently a beta function with 1 added
        to the first beta parameter.
    return_extras : bool
        If this is False, then only the random sample will be returned.
        If true, then extra information is returned that is mainly of interest
        for verification.

    Returns
    -------
    rvs : ndarray
        Multivariate sample with ``size`` observations drawn from the Beta
        Copula.

    Notes
    -----
    Status: experimental, API will change.
    r   Nsizec                 (    g | ]} |          S r   r   ).0xiibwkfuncs     r   
<listcomp>zrvs_kernel.<locals>.<listcomp>j   s#    ;;;sEE#rNN;;;r   )r$   _kernel_rvs_beta1r!   r   randintcolumn_stackT)
sampler8   r<   k_funcreturn_extrasnidxxikrvsr=   s
     `      @r   
rvs_kernelrJ   C   s    D 	QA~!
)

Aqt

,
,C	B?;;;;;bd;;;<<D S"}r   c                 n    t           j                            | |z  dz   d| z
  |z  dz   | j                  S )Nr   r7   )r   betar   r$   r   r<   s     r   _kernel_rvs_betarN   r   s3    :>>!b&1*q1ulQ&6QW>EEEr   c                 Z    t           j                            | |z  d| z
  |z  dz             S )Nr   )r   rL   r   rM   s     r   r?   r?   w   s+     :>>!b&1q5B,"2333r   )r   NF)r4   numpyr!   scipyr   statsmodels.tools.rng_qrngr   (statsmodels.distributions.copula.copulasr   r   rJ   rN   r?   r   r   r   <module>rT      s               9 9 9 9 9 9 ; ; ; ; ; ;1F 1F 1F 1F 1F 1F 1F 1Fh, , , ,^F F F
4 4 4 4 4r   