arbitragelab.copula_approach.archimedean.n13
Module that houses N13 copula class.
Module Contents
Classes
N13 Copula (Nelsen 13).  | 
- class N13(theta: float = None, threshold: float = 1e-10)
 Bases:
arbitragelab.copula_approach.base.CopulaN13 Copula (Nelsen 13).
- __slots__ = ()
 
- sample(num: int = None, unif_vec: numpy.array = None) numpy.array
 Generate pairs according to P.D.F., stored in a 2D np.array.
User may choose to side-load independent uniformly distributed data in [0, 1].
- Parameters:
 num – (int) Number of points to generate.
unif_vec – (np.array) Shape=(num, 2) array, two independent uniformly distributed sets of data. Default uses numpy pseudo-random generators.
- Returns:
 (np.array) Shape=(num, 2) array, sampled data for this copula.
- c(u: float, v: float) float
 Calculate probability density of the bivariate copula: P(U=u, V=v).
Result is analytical.
- Parameters:
 u – (float) A real number in [0, 1].
v – (float) A real number in [0, 1].
- Returns:
 (float) The probability density (aka copula density).
- C(u: float, v: float) float
 Calculate cumulative density of the bivariate copula: P(U<=u, V<=v).
Result is analytical.
- Parameters:
 u – (float) A real number in [0, 1].
v – (float) A real number in [0, 1].
- Returns:
 (float) The cumulative density.
- condi_cdf(u, v) float
 Calculate conditional probability function: P(U<=u | V=v).
Result is analytical.
Note: This probability is symmetric about (u, v).
- Parameters:
 u – (float) A real number in [0, 1].
v – (float) A real number in [0, 1].
- Returns:
 (float) The conditional probability.
- static theta_hat(tau: float) float
 Calculate theta hat from Kendall’s tau from sample data.
- Parameters:
 tau – (float) Kendall’s tau from sample data.
- Returns:
 (float) The associated theta hat for this very copula.
- describe() pandas.Series
 Print the description of the copula’s name and parameter as a pd.Series.
Note: the descriptive name is different from the copula’s class name, but its full actual name. E.g. The Student copula class has its descriptive name as ‘Bivariate Student-t Copula’.
- Return description:
 (pd.Series) The description of the copula, including its descriptive name, class name, and its parameter(s) when applicable.
- get_cop_density(u: float, v: float, eps: float = 1e-05) float
 Get the copula density c(u, v).
Result is analytical. Also the u and v will be remapped into [eps, 1-eps] to avoid edge values that may result in infinity or NaN.
- Parameters:
 u – (float) A real number in [0, 1].
v – (float) A real number in [0, 1].
eps – (float) Optional. The distance to the boundary 0 or 1, such that the value u, v will be mapped back. Defaults to 1e-5.
- Returns:
 (float) The probability density (aka copula density).
- get_cop_eval(u: float, v: float, eps: float = 1e-05) float
 Get the evaluation of copula, equivalently the cumulative joint distribution C(u, v).
Result is analytical. Also the u and v will be remapped into [eps, 1-eps] to avoid edge values that may result in infinity or NaN.
- Parameters:
 u – (float) A real number in [0, 1].
v – (float) A real number in [0, 1].
eps – (float) Optional. The distance to the boundary 0 or 1, such that the value u, v will be mapped back. Defaults to 1e-5.
- Returns:
 (float) The evaluation of copula (aka cumulative joint distribution).
- get_condi_prob(u: float, v: float, eps: float = 1e-05) float
 Calculate conditional probability function: P(U<=u | V=v).
Result is analytical. Also the u and v will be remapped into [eps, 1-eps] to avoid edge values that may result in infinity or NaN.
Note: This probability is symmetric about (u, v).
- Parameters:
 u – (float) A real number in [0, 1].
v – (float) A real number in [0, 1].
eps – (float) Optional. The distance to the boundary 0 or 1, such that the value u, v will be mapped back. Defaults to 1e-5.
- Returns:
 (float) The conditional probability.
- get_log_likelihood_sum(u: numpy.array, v: numpy.array) float
 Get log-likelihood value sum.
- Parameters:
 u – (np.array) 1D vector data of X pseudo-observations. Need to be uniformly distributed [0, 1].
v – (np.array) 1D vector data of Y pseudo-observations. Need to be uniformly distributed [0, 1].
- Returns:
 (float) Log-likelihood sum value.
- fit(u: numpy.array, v: numpy.array) float
 Fit copula to empirical data (pseudo-observations). Once fit, self.theta is updated.
- Parameters:
 u – (np.array) 1D vector data of X pseudo-observations. Need to be uniformly distributed [0, 1].
v – (np.array) 1D vector data of Y pseudo-observations. Need to be uniformly distributed [0, 1].
- Returns:
 (float) Theta hat estimate for fit copula.
- plot_cdf(plot_type: str = '3d', grid_size: int = 50, levels: list = None, **kwargs) matplotlib.pyplot.axis
 Plot either ‘3d’ or ‘contour’ plot of copula CDF.
- Parameters:
 plot_type – (str) Either ‘3d’ or ‘contour’(2D) plot.
grid_size – (int) Mesh grid granularity.
kwargs – (dict) User-specified params for ‘ax.plot_surface’/’plt.contour’.
levels – (list) List of float values that determine the number and levels of lines in a contour plot. If not provided, these are calculated automatically.
- Returns:
 (plt.axis) Axis object.
- plot_scatter(num_points: int = 100) matplotlib.axes.Axes
 Plot copula scatter plot of generated pseudo-observations.
- Parameters:
 num_points – (int) Number of samples to generate.
- Returns:
 (plt.axis) Axis object.
- plot_pdf(plot_type: str = '3d', grid_size: int = 50, levels: list = None, **kwargs) matplotlib.figure.Figure
 Plot either ‘3d’ or ‘contour’ plot of copula PDF.
- Parameters:
 plot_type – (str) Either ‘3d’ or ‘contour’(2D) plot.
grid_size – (int) Mesh grid granularity.
levels – (list) List of float values that determine the number and levels of lines in a contour plot. If not provided, these are calculated automatically.
- Returns:
 (plt.axis) Axis object.