Member-only story

Simulating and Modeling Statistical Distributions via bayes.js

Jake Jing
2 min readApr 3, 2023

--

I have been thinking about building a web app for simulating data with given parameters and recovering the parameters with Bayesian MCMC samplers in JavaScript. This web app can not only make the procedures more transparent, but also help us understand the magic of the Bayesian MCMC approach. More importantly, I have benefited from this simulation-based way of thinking, so I would like to promote it in my blog.

I looked for some off-the-shelf software online and found a JS library bayes.js developed by Rasmus Bååth. He also wrote a blog to introduce the library. I strongly recommend you first to read his blog to get some key ideas behind it. The library includes an adaptive MCMC sampler (AmwgSampler) in mcmc.js and some common probability distributions in distributions.js. There are also some examples, e.g., you can use bayes.js to fit a Normal distribution and plot the posterior distributions of parameters via plotly.js.

This blog heavily relies on Bååth’s library and his implementations. I appreciate his efforts to build a web app for Bayesian data analysis in JavaScript. Here I made some slight adjustments.

(1) Include the data generating process by using d3.js; You can type

--

--

Jake Jing
Jake Jing

Written by Jake Jing

Programming, Data science & Deep learning!

No responses yet