Yet another vine copula package, using PyTorch.
- C/D/R-Vine full-sampling/ quantile-regression/ conditional-sampling, all in one package
- Flexible sampling order for experienced users
- Vectorized tensor computation with GPU (
device='cuda'
) support - Shorter runtimes for higher dimension simulations
- Pure
Python
library, inspired by pyvinecopulib on Windows, Linux, MacOS - IO and visualization support
Visit the ./examples/
folder for .ipynb
Jupyter notebooks.
- By
pip
fromPyPI
:
pip install torchvinecopulib torch
- Or
pip
from./dist/*.whl
or./dist/*.tar.gz
in this repo. Need to use proper file name.
# inside project root folder
pip install ./dist/torchvinecopulib-1.0.4-py3-none-any.whl
# or
pip install ./dist/torchvinecopulib-1.0.4.tar.gz
(Recommended) uv for Dependency Management and Packaging
After git clone https://github.com/TY-Cheng/torchvinecopulib.git
, cd
into the project root where pyproject.toml
exists,
# inside project root folder
uv sync --extra cpu -U
# or
uv sync --extra cu126 -U
# inside the `./pyproject.toml` file;
fastkde = "*"
numpy = "*"
pyvinecopulib = "*"
python = ">=3.12"
scipy = "*"
# optional to facilitate customization
torch = [
{ index = "torch-cpu", extra = "cpu" },
{ index = "torch-cu126", extra = "cu126" },
]
For PyTorch with cuda
:
pip install torch --index-url https://download.pytorch.org/whl/cu126 --force-reinstall
# check cuda availability
python -c "import torch; print(torch.cuda.is_available())"
Tip
macOS users should set device='cpu'
at this stage, for using device='mps'
won't support dtype=torch.float64
.
-
Visit GitHub Pages website
-
Or build by yourself (need
Sphinx
, themefuro
and the GNUmake
)
# inside project root folder
sphinx-apidoc -o ./docs ./torchvinecopulib && cd ./docs && make html && cd ..
# if using uv
uv run sphinx-apidoc -o docs torchvinecopulib/ --separate
uv run sphinx-build docs docs/_build/html
# inside project root folder
python -m pytest ./tests
# coverage report
coverage run -m pytest ./tests && coverage html
# if using uv
uv run coverage run --source=torchvinecopulib -m pytest ./tests
uv run coverage report -m
VineCop.rosenblatt
- replace
dict
withtorch.Tensor
using somemod
- vectorized union-find
- flatten
_visit
logic examples/someapplications.ipynb
- flatten dynamic nested dicts into tensors
fastkde.pdf
ontotorch.Tensor
We welcome contributions, whether it's a bug report, feature suggestion, code contribution, or documentation improvement.
- If you encounter any issues with the project or have ideas for new features, please open an issue on GitHub or privately email us. Make sure to include detailed information about the problem or feature request, including steps to reproduce for bugs.
- Fork the repository and create a new branch from the
main
branch. - Make your changes and ensure they adhere to the project's coding style and conventions.
- Write tests for any new functionality and ensure existing tests pass.
- Commit your changes with clear and descriptive commit messages.
- Push your changes to your fork and submit a pull request to the
main
branch of the original repository.
- Keep pull requests focused on addressing a single issue or feature.
- Include a clear and descriptive title and description for your pull request.
- Make sure all tests pass before submitting the pull request.
- If your pull request addresses an open issue, reference the issue number in the description using the syntax
#issue_number
. - in-place ops can be slower
- torch.jit.script can be slower
This project is released under the MIT License (© 2024- Tuoyuan Cheng, Kan Chen).
See LICENSE for the full text, including our own grant of rights and disclaimer.
See the “Third-Party Dependencies” section in LICENSE for details on the PyTorch
, FastKDE
, and pyvinecopulib
licenses that govern those components.