Skip to content

Multivariate normal CDF computation for tensors. Implementation of closed form derivatives.

License

Notifications You must be signed in to change notification settings

hkmeme/torch-mvnorm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Torch-MvNorm

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

DOI


About Torch-MvNorm

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

Installation

Dependencies

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

Get the Torch-MvNorm source

git clone --recursive https://github.com/SebastienMarmin/torch-mvnorm
cd torch-mvnorm

Install Torch-MvNorm

Compile Fortran and build the interface:

python3 setup.py build_ext --inplace

Test the code

python3 tests/test_general.py

Getting Started

Communication and contribution

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.

License

Torch-MvNorm is under GNU General Public License. See the LICENSE file.

About

Multivariate normal CDF computation for tensors. Implementation of closed form derivatives.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Fortran 58.0%
  • Python 41.5%
  • Other 0.5%