{"id":37624270,"url":"https://github.com/pberkes/empirical_copula","last_synced_at":"2026-01-16T10:45:34.298Z","repository":{"id":65059484,"uuid":"547137489","full_name":"pberkes/empirical_copula","owner":"pberkes","description":"A Python library to  compute and plot 2D empirical copulas of discrete data (ordinal or categorical)","archived":false,"fork":false,"pushed_at":"2022-12-23T10:20:41.000Z","size":1276,"stargazers_count":9,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-23T03:45:40.318Z","etag":null,"topics":["plotting","statistics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pberkes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-07T07:34:25.000Z","updated_at":"2024-11-16T14:57:45.000Z","dependencies_parsed_at":"2023-01-11T16:00:39.056Z","dependency_job_id":null,"html_url":"https://github.com/pberkes/empirical_copula","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pberkes/empirical_copula","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pberkes%2Fempirical_copula","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pberkes%2Fempirical_copula/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pberkes%2Fempirical_copula/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pberkes%2Fempirical_copula/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pberkes","download_url":"https://codeload.github.com/pberkes/empirical_copula/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pberkes%2Fempirical_copula/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plotting","statistics"],"created_at":"2026-01-16T10:45:33.718Z","updated_at":"2026-01-16T10:45:34.270Z","avatar_url":"https://github.com/pberkes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# empirical_copula\n\n`empirical_copula` is a Python library to compute and plot 2D empirical copulas of discrete \ndata (ordinal or categorical).\n\n## What is an empirical copula? \n\nA copula is a statistical object that captures the dependencies between two random variables, \nindependently of their marginal distribution. For instance, as in the figure below, two \nvariables might be dependent only in their low tails (Fig. 1).\n\n![Figure 1 (Berkes et al., Cosyne 2008)](figures/CopulaIllustration_BerkesEtAl_Cosyne08.png)\n\nStatisticians have defined parametric families of copulas that describe different kind of \ndependencies between continuous variables (Fig. 2). \n\n![Figure 2 (Berkes et al., Cosyne 2009)](figures/CopulasZoo_BerkesEtAl_NIPS08.png)\n\nAn empirical copula visualizes the dependency structure observed in samples from two random \nvariables. \n\nFor discrete (or discretized) variables, the empirical copula shows on the two axes the \ncumulative observed frequency of the values of each variable. The values in the copulas is the \nempirical joint pmf in that space. Independent variables in the copula space have uniform \nprobability, and so the values in the copula can be interpreted as deviations from independence.\n\n## An example\n\nAn example is going to make this much clearer. Figure 3 shows the log empirical copula between a \nquality score and house price from the `house_price` OpenML dataset.\n\nThe spacing of the lines on the axes show the frequencies of the values of the two variables. \nSince the area of each combination of values is the product of the frequency, independent \nvariables would have a uniform probability of 1.0 in each of the cases, or 0.0 in logarithmic \nspace.\n\nThe value of ~0.5 for the pair (quality=7, price=225k) means that that pair has been observed \n10^0.5 ~= 3.2 times more often than one would expect in independent variables. This examples \ndemonstrates a strong dependencies between the quality score and the hose price, especially in \nthe high and low tails of extreme high and low quality and prices, which are observed 10x more \noften than in the uniform case. \n\n![Figure 3, Example copula](figures/CopulaExample.png)\n\n## Statistical significance\n\nWe evaluate the statistical significance of the observed deviations from independence using \nbootstrapping: we destroy the dependencies between the variables by resampling them replacement\nindependently from each other. Doing this many times gives us an estimate of the distribution \nof the frequencies we would observe with the same marginal distribution if the variables were \nindependent. We can then look at how extreme what we observe is compared to this null-hypothesis \ndistribution and derive a significance level.\n\n![Figure 4, Example copula significance](figures/CopulaExampleSignificance.png)\n\n## Examples\n\nTo learn how to use `emipirical_copula`, it's easiest to look at the examples notebook in the\ngit repository: [GitHub examples notebooks](https://github.com/pberkes/empirical_copula/tree/main/examples)\n\n## References\n\n- Figure 1:\nCosyne08 abstract and poster: Berkes, P., Pillow, J., and Wood, F. (2008).\nCharacterizing neural dependencies with Poisson copula models. Cosyne 2008, Salt Lake City (abstract).\n\n- Figure 2:\nBerkes, P., Wood, F., and Pillow, J. (2009).\nCharacterizing neural dependencies with copula models. Advances in Neural Information Processing Systems, 21.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpberkes%2Fempirical_copula","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpberkes%2Fempirical_copula","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpberkes%2Fempirical_copula/lists"}