A package for calculate and draw copula density
Project description
Package info
Package name: copuladensity-pkg
Version: 0.0.1
Author: Shanshan Wang
Description: this package is used to calcualte and draw copula density of two correlated time series.
Python requires version >=3.6
Install
pip install copuladensity-pkg
Uninstall
pip uninstall copuladensity-pkg
How to use
from copula_package import copula_density
Functions
- copula_density.sampling_two_corr_time_series(mean,cov,n)
function: sample two correlated time series
mean: a list of two mean values for two time series, respectively, e.g., mean = (1, 2)
cov: a 2-d array of diagonal covariances between two time series, e.g., cov = [[1, 1], [1, 2]]
n: the length of each time series
return x, y, z
x: a list of time series
y: a list of time series
z: a pandas dataframe for x and y
- copula_density.draw_histogram(x,n_bins,label_x)
function: draw historgram of a time series, where the hight of histogram shows the probability density
x: a list of time series
n_bins: the number of bins in the histogram
label_x: a string for the label of x axis in the figure
return: none
- copula_density.draw_joint_distribution(z,label_x,label_y)
function: draw joint distribution of two time series z: a pandas dataframe with two columns, where each column contains a time series
label_x: a string for the label of x axis in the figure
label_y: a string for the label of y axis in the figure
return: none
- copula_density.qrank_data(x)
function: calculate the quantile of ranking data x
x: a list of time series
return: qx
qx: a list of quantiles
- copula_density.calc_copula_density(qx,qy,nx,ny)
function: calculate copula density of two time series
qx: a list of quantiles
qy: a list of quantiles
nx: the number of bins for qx
nx: the number of bins for qy
return: cop_den
cop_den: a $nx\times ny$ 2-dimentional array of copula densities
- copula_density.draw_heatmap(matrix,label_qx,label_qy)
function: draw heatmap for copula densities
matrix: 2-dimensional array of copula densities
label_x: a string for the label of x axis in the figure
label_y: a string for the label of y axis in the figure
return: none
- copula_density.draw_surface(matrix,label_qx,label_qy)
function: draw surface for copula densities
matrix: 2-dimensional array of copula densities
label_x: a string for the label of x axis in the figure
label_y: a string for the label of y axis in the figure
return: none
- copula_density.draw_bar3d(matrix,label_qx,label_qy)
function: draw 3-dimensional bars for copula densities
matrix: 2-dimensional array of copula densities
label_x: a string for the label of x axis in the figure
label_y: a string for the label of y axis in the figure
return: none
An example
from copula_package import copula_density
# sampling two time series
mean = (1, 2)
cov = [[1, 1], [1, 2]]
n=10000
x,y,z=copula_density.sampling_two_corr_time_series(mean,cov,n)
# draw histogram and joint histogram of time series
n_bins=50
label_x='x'
label_y='y'
copula_density.draw_histogram(x,n_bins,label_x)
copula_density.draw_joint_distribution(z,label_x,label_y)
# calculate quantiles
qx=copula_density.qrank_data(x)
qy=copula_density.qrank_data(y)
# calcualte copula density
nx=20
ny=20
cop_den=copula_density.calc_copula_density(qx,qy,nx,ny)
# draw copula density in three ways
label_qx='Quantile(x)'
label_qy='Quantitle(y)'
copula_density.draw_heatmap(cop_den,label_qx,label_qy)
copula_density.draw_surface(cop_den,label_qx,label_qy)
copula_density.draw_bar3d(cop_den,label_qx,label_qy)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for copuladensity_pkg-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e82b5b480d604df6d84c0950d05a15fbd32ddef1b48985ee0f38b7e3adb21102 |
|
MD5 | 6625e71e6d499b3827757d3dd3c9ca3e |
|
BLAKE2b-256 | de97590e43fb294306fe7ad927f95d8c98c1aec2694cd48eaccb3cf6ad08f8ab |