Giter Site home page Giter Site logo

justcodebase / copulas.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lrnv/copulas.jl

0.0 0.0 0.0 8.19 MB

A fully `Distributions.jl`-compliant copula package

Home Page: https://lrnv.github.io/Copulas.jl/

License: MIT License

Julia 93.53% TeX 6.47%

copulas.jl's Introduction

Copulas.jl

A fully `Distributions.jl`-compliant copula package

Stable Dev
Project Status: Active – The project has reached a stable, usable state and is being actively developed. Build Status Aqua QA
License: MIT ColPrac: Contributor's Guide on Collaborative Practices for Community Packages Code Style: Blue

Copulas.jl brings most standard copula features into native Julia: random number generation, pdf and cdf, fitting, copula-based multivariate distributions through Sklar's theorem, etc. Since copulas are distribution functions, we fully comply with the Distributions.jl API. This allows interoperability with the broader ecosystem, based on this API, such as, e.g., Turing.jl.

Usually, people that use and work with copulas turn to R, because of the amazing package R::copula. While well-maintained and regularly updated, R::copula is a mixture of obscure, heavily optimized C code and more standard R code, which makes it a complicated code base for readability, extensibility, reliability and maintenance.

This is an attempt to provide a very light, fast, reliable and maintainable copula implementation in native Julia. One of the notable benefits of such a native implementation (among others) is the floating point type agnosticity, i.e. compatibility with BigFloat, DoubleFloats, MultiFloats, etc.

The package revolves around two main types:

  • Copula, an abstract mother type for all the copulas in the package
  • SklarDist, a distribution type that allows construction of a multivariate distribution by specifying the copula and the marginals through Sklar's theorem.

Warning: This is fairly experimental work, use with caution.

Getting started

The package is registered in Julia's General registry so you may simply install the package by running :

] add Copulas

The API contains random number generation, cdf and pdf evaluation, and the fit function from Distributions.jl. A typical use case might look like this:

using Copulas, Distributions, Random
X₁ = Gamma(2,3)
X₂ = Pareto()
X₃ = LogNormal(0,1)
C = ClaytonCopula(3,0.7) # A 3-variate Clayton Copula with θ = 0.7
D = SklarDist(C,(X₁,X₂,X₃)) # The final distribution

simu = rand(D,1000) # Generate a dataset

# You may estimate a copula using the `fit` function:= fit(SklarDist{ClaytonCopula,Tuple{Gamma,Normal,LogNormal}}, simu)

The list of availiable copula models is very large, check it out on our documentation !

The general implementation philosophy is for the code to follow the mathematical boundaries of the implemented concepts. For example, this is the only implementation we know (in any language) that allows for all Archimedean copulas to be sampled: we use the Williamson transformation for non-standard generators, including user-provided black-box ones.

Feature comparison

There are competing packages in Julia, such as BivariateCopulas.jl which only deals with a few models in bivariate settings but has very nice graphs, or DatagenCopulaBased.jl, which only provides sampling and does not have exactly the same models as Copulas.jl. While not fully covering out both of these package's functionality (mostly because the three projects chose different implementation paths), Copulas.jl brings, as a key feature, the compliance with the broader ecosystem. The following table provides a feature comparison between the three:

Copulas.jl DatagenCopulaBased.jl BivariateCopulas.jl
Distributions.jl's API ✔️ ✔️
Fitting ✔️
Plotting ✔️
Available copulas
- Classic Bivariate ✔️ ✔️ ✔️
- Classic Multivariate ✔️ ✔️
- Archimedeans ✔️ (All of them) ⚠️ Selected ones ⚠️Selected ones
- Obscure Bivariate ✔️
- Archimedean Chains ✔️

Since our primary target is maintainability and readability of the implementation, we did not consider the efficiency and the performance of the code yet. Proper benchmarks will come in the near future.

Contributions are welcome

If you want to contribute to the package, ask a question, found a bug or simply want to chat, do not hesitate to open an issue on this repo. General guidelines on collaborative practices (colprac) are available at https://github.com/SciML/ColPrac.

Citation

Do not hesitate to star this repository to show support. If you use this package in your researches, please cite it with the following bibtex code:

@article{Laverny2024,
    author = {Oskar Laverny and Santiago Jimenez}, 
    title = {Copulas.jl: A fully Distributions.jl-compliant copula package},
    journal = {Journal of Open Source Software},
    doi = {10.21105/joss.06189}, 
    url = {https://doi.org/10.21105/joss.06189}, 
    year = {2024}, 
    publisher = {The Open Journal}, 
    volume = {9}, 
    number = {94}, 
    pages = {6189}
}

copulas.jl's People

Contributors

lrnv avatar santymax98 avatar dependabot[bot] avatar osorensen avatar github-actions[bot] avatar mlkrock avatar szcf-weiya avatar herbps10 avatar lmiq avatar pdeffebach avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.