Torch-MvNorm is a small Python package that allows
- Multivariate normal density integration, in particular computing cumulative distribution functions (CDFs)
- Partial differentiaton of CDFs through implementation of closed-form formulas (see e.g. Marmin et al. 2019, appendix 6)
- Quantities manipulation within PyTorch tensor-based framework
Torch-MvNorm is a library that consists of the two following components:
- mvnorm.fotran_interface -- PyTorch-Fortan bridge for Alan Genz's routine
- mvnorm.autograd -- implementation of the formula of the multivariate normal CDF gradient
-
Install gfortran and python-dev
sudo apt-get update -y
sudo apt-get install gfortran
sudo apt-get install python-dev
- Install joblib python modules
sudo apt-get install -y python3-joblib
- Check in your python3 console
from Cython.Distutils import build_ext
. If Cython is not already installed, you can try:
python3 -m pip install Cython
git clone --recursive https://github.com/SebastienMarmin/torch-mvnorm
cd torch-mvnorm
Compile Fortran and build the interface:
python3 setup.py build_ext --inplace
python3 tests/test_general.py
- Run the code on small examples.
- Have a look at the documentation.
I welcome all contributions. Please let me know if you encounter a bug by filing an issue. Feel free to request a feature, make suggestions, share thoughts, etc, using the GitHub plateform or contacting me.
If you came across this work for a publication, please considere citing me for the code or for the mathematical derivation.
Torch-MvNorm is under GNU General Public License. See the LICENSE file.