https://github.com/diku-dk/sml-sobol
Standard ML library for Sobol sequences
https://github.com/diku-dk/sml-sobol
smlpkg
Last synced: 4 months ago
JSON representation
Standard ML library for Sobol sequences
- Host: GitHub
- URL: https://github.com/diku-dk/sml-sobol
- Owner: diku-dk
- License: mit
- Created: 2021-02-12T12:09:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-01T10:14:27.000Z (over 2 years ago)
- Last Synced: 2025-10-11T09:43:09.435Z (8 months ago)
- Topics: smlpkg
- Language: Standard ML
- Homepage:
- Size: 11.7 KB
- Stars: 7
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sml-sobol [](https://github.com/diku-dk/sml-sobol/actions)
Standard ML package for generating Sobol sequences.
This library is a convenient and modular library for efficiently
generating large quantities of quasi-random numbers (in multiple
dimensions) in a parallel and purely functional setting. Sobol numbers
are particularly useful for Monte Carlo simulations, which are a core
application of massive parallelism.
Sobol sequences are quasi-random low-discrepancy sequences frequently
used in Monte-Carlo algorithms and they generalize nicely to multiple
dimensions. Sobol sequences are superior to traditional pseudo-random
numbers for numeric integration (by Monte-Carlo simulation). Sobol
sequences simply span the space much better than their pseudo-random
counterparts. In fact, it has been shown that while the value of a
multi-dimensional integral for a continuous and differentiable
function can be approximated with a convergence rate of _1/n_ using
pseudo-random numbers, using Sobol sequences, the convergence rate is
_1/sqrt(n)_.
For a discussion of the implementation, please consult [1].
## Overview of MLB files
- `lib/github.com/diku-dk/sml-sobol/sobol.mlb`:
- **signature** [`SOBOL_DIR`](lib/github.com/diku-dk/sml-sobol/sobol_dir.sig)
- **structure** `SobolDir50` :> `SOBOL_DIR`
- **signature** [`SOBOL`](lib/github.com/diku-dk/sml-sobol/sobol.sig)
- **functor** `Sobol (sig val D : int structure SobolDir : SOBOL_DIR end) :> SOBOL`
## Installing the package
This library is set up to work well with the SML package manager
[smlpkg](https://github.com/diku-dk/smlpkg). To use the package, in
the root of your project directory, execute the command:
```
$ smlpkg add github.com/diku-dk/sml-sobol
```
This command will add a _requirement_ (a line) to the `sml.pkg` file in your
project directory (and create the file, if there is no file `sml.pkg`
already).
To download the library into the directory
`lib/github.com/diku-dk/sml-sobol`, execute the command:
```
$ smlpkg sync
```
You can now reference the `mlb`-file using relative paths from within
your project's `mlb`-files.
Notice that you can choose either to treat the downloaded package as
part of your own project sources (vendoring) or you can add the
`sml.pkg` file to your project sources and make the `smlpkg sync`
command part of your build process.
## Using the package
See the files
[sobol-test.mlb](lib/github.com/diku-dk/sml-sobol/test/sobol-test.mlb)
and
[sobol-test.sml](lib/github.com/diku-dk/sml-sobol/test/sobol-test.sml)
for a demonstration of how to use the package. See below for an image created using `sobol-test.exe`.
## Authors
Copyright (c) 2015-2021 Martin Elsman, Troels Henriksen, University of
Copenhagen, DIKU. Partly ported from the [Futhark Sobol library](https://github.com/diku-dk/sobol).
## References
[1] Troels Henriksen, Martin Elsman, and Cosmin E. Oancea. __Modular
Acceleration: Tricky Cases of Functional High-Performance
Computing__. In _Proceedings of the 6th ACM SIGPLAN workshop on
Functional High-Performance Computing (FHPC ‘18)_. St. Louis, Missouri,
USA. September 2018.
## Appendix : Output Image for `sobol-test.exe`
The image below is created with the following commands:
```
$ cd lib/github.com/diku-dk/sml-sobol/test/
$ make sobol-test.exe
$ ./sobol-test.exe -N 10000 -f out.ppm && convert out.ppm out.png
```
Here is the image:
