Published
Edited
Mar 9, 2019
1 fork
14 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function f(x) { // Convex potential
return (3 * (x[0] + .8) * (x[0] + .8) + 7 * x[1] * x[1]);
}
Insert cell
function df(x) {
// Gradient of the potential [ df/dx_1, df/dx_2 ]
return [6 * (x[0] + .8), 14 * x[1]];
}
Insert cell
Insert cell
function langevin(f, x, delta) {
var d = df(x);
return [x[0] - delta * d[0] + Math.sqrt(2*delta) * Gaussian(),
x[1] - delta * d[1] + Math.sqrt(2*delta) * Gaussian()];
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function coupled_langevin(f, x, delta) {
var noise = [Gaussian(), Gaussian()];
var next = [];
for (var i = 0; i < x.length; ++i) {
var d = df(x[i]);
next.push([x[i][0] - delta * d[0] + Math.sqrt(2*delta) * noise[0],
x[i][1] - delta * d[1] + Math.sqrt(2*delta) * noise[1]]);
}
return next;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more