blob: 8a061c3e8997b82856bfb8d773fe077e87c314e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

This repository is the source code accompanying the following papers.
 [An O(n) algorithm for generating uniform random vectors in ndimensional cones](https://arxiv.org/abs/2101.00936)
 [An algorithm for estimating volumes and other integrals in n dimensions](https://arxiv.org/abs/2007.06808)
However, most of the code for [An O(n) algorithm for generating
uniform random vectors in ndimensional
cones](https://arxiv.org/abs/2101.00936) has been released as a
separate library—sambal. See [PyPI
page](https://pypi.org/project/sambal/) and
[source](https://git.systemreboot.net/sambal).
# 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 `distributionvolumes.py`, `distributionintegrals.py` and
`spheroid.py`. Run those scripts as
```
$ python3 distributionvolumes.py
$ python3 distributionintegrals.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.
