Emcee.js
Just a slick little Markov chain Monte Carlo sampler written in Javascript...
Install / Use
/learn @dfm/Emcee.jsREADME
emcee.js
This a Javascript implementation of emcee.
Usage
-
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; }; -
Initialize an
EnsembleSamplerobject:var sampler = new emcee.EnsembleSampler(lnprobfn); -
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]); -
Run the heck out of it and take 1000 samples:
sampler.runMCMC(initialPosition, 1000); -
The acceptance fraction is
sampler.acceptanceFractionand the chain is stored insampler.chain. -
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.
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
