Skip to main content

A package for calculate and draw copula density

Project description

Package info

Package name: copuladensity-pkg
Version: 0.0.3
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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

copuladensity-pkg-0.0.3.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

copuladensity_pkg-0.0.3-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page