This repository is the source code accompanying the following papers. - An O(n) algorithm for generating uniform random vectors in n-dimensional cones - An algorithm for estimating volumes and other integrals in n dimensions
However, most of the code for An O(n) algorithm for generating uniform random vectors in n-dimensional cones has been released as a separate library—sambal. See PyPI page and source.
Dependencies
The code depends on the following dependencies. Please install them before running the scripts. A python virtual environment may be an easy way to do this.
- Python 3
- matplotlib
- numpy
- scipy
- sambal
Run
The core functions are in nsmc.py
. The experiments are in the
scripts distribution-volumes.py
, distribution-integrals.py
and
spheroid.py
. Run those scripts as
$ python3 distribution-volumes.py
$ python3 distribution-integrals.py
$ python3 spheroid.py
Plots of the number of samples versus the dimension get written to the current directory. Play around with the number of trials, dimensions, and relative error tolerances in the scripts.