https://github.com/dfm/emcee.js
Just a slick little Markov chain Monte Carlo sampler written in Javascript...
https://github.com/dfm/emcee.js
Last synced: about 1 year ago
JSON representation
Just a slick little Markov chain Monte Carlo sampler written in Javascript...
- Host: GitHub
- URL: https://github.com/dfm/emcee.js
- Owner: dfm
- License: mit
- Created: 2012-07-06T17:04:00.000Z (almost 14 years ago)
- Default Branch: main
- Last Pushed: 2020-06-12T18:17:42.000Z (almost 6 years ago)
- Last Synced: 2025-03-27T10:21:38.836Z (about 1 year ago)
- Language: JavaScript
- Homepage: http://danfm.ca/emcee.js/
- Size: 84 KB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE.markdown
Awesome Lists containing this project
README
emcee.js
========
This a Javascript implementation of [emcee](http://danfm.ca/emcee).
Usage
-----
1. Write down the density that you want to sample:
var lnprobfn = function (x) {
var i, result = 0.0;
for (i = 0; i < x.length; i++) result -= 0.5 * x[i] * x[i];
return result;
};
2. Initialize an `EnsembleSampler` object:
var sampler = new emcee.EnsembleSampler(lnprobfn);
3. Make an initial guess at positions for 100 walkers in 3 dimensions,
in this particular case, it's going to be a small Gaussian ball:
var initialPosition = emcee.smallBall(100, [0.1, 2, -0.5], [1.0, 0.1, 0.5]);
4. Run the heck out of it and take 1000 samples:
sampler.runMCMC(initialPosition, 1000);
5. The acceptance fraction is `sampler.acceptanceFraction` and the chain
is stored in `sampler.chain`.
6. Now make some sort of **sick front end**!
Example
-------
To see an example, run `python -m SimpleHTTPServer 8000` in the root directory of this
repository and navigate to [localhost:8000/examples](http://localhost:8000/examples).