
    "g                     ^    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y)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                 &    t         |   |       y )N)k_dim)super__init__)selfr	   	__class__s     k/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/statsmodels/distributions/copula/other_copulas.pyr   zIndependenceCopula.__init__%   s    u%    c                 .    |dk7  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   c                 x    | j                  |       t        |      }|j                  || j                  f      }|S )N)r   r   randomr	   )r   nobsr   random_staterngxs         r   rvszIndependenceCopula.rvs/   s6    $ .JJdjj)*r   c                 p    t        j                  |      }t        j                  |j                  d d       S )N)npasarrayonesshaper   ur   s      r   pdfzIndependenceCopula.pdf5   s(    JJqMwwqwws|$$r   c                 0    t        j                  |d      S )Nr   )axis)r   prodr#   s      r   cdfzIndependenceCopula.cdf9   s    wwqr""r   c                      y)Nr   r   )r   s    r   tauzIndependenceCopula.tau<   s    r   c                     t        d      )Nz PDF is constant over the domain.)NotImplementedError)r   r   s     r   plot_pdfzIndependenceCopula.plot_pdf?   s    !"DEEr   )   )   r   N)r   )__name__
__module____qualname____doc__r   r   r   r%   r)   r+   r.   __classcell__)r   s   @r   r   r      s,    *&%#Fr   r   c           	         | j                   d   }|t        }t        j                  j	                  d||      }| |   }t        j
                  |j                  D 	cg c]  }	 |	|       c}	      }
|r|
||fS |
S c c}	w )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   size)r"   _kernel_rvs_beta1r   r   randintcolumn_stackT)sampler8   bwk_funcreturn_extrasnkfuncidxxixiikrvss              r   
rvs_kernelrG   C   s|    D 	QA~!
))

Aqt

,C	B??bdd;sE#rN;<DS"} <s   A<c                 x    t         j                  j                  | |z  dz   d| z
  |z  dz   | j                        S )Nr0   r7   )r   betar   r"   r   r>   s     r   _kernel_rvs_betarK   r   s4    ::>>!b&1*q1ulQ&6QWW>EEr   c                 Z    t         j                  j                  | |z  d| z
  |z  dz         S )Nr0   )r   rI   r   rJ   s     r   r9   r9   w   s*     ::>>!b&1q5B,"233r   )r0   NF)r4   numpyr   scipyr   statsmodels.tools.rng_qrngr   (statsmodels.distributions.copula.copulasr   r   rG   rK   r9   r   r   r   <module>rQ      s8      9 ;1F 1Fh,^F
4r   