Published
Edited
Oct 13, 2021
3 stars
Chandrupatla’s root-finding methodSidi’s root-finding methodRegular numbersDruidJS workerNatural breaksDistance to a segmentRay out of a convex hullWord Tour: 40k words and their friendsHello, @thi.ng/grid-iteratorsHead/tail breaksPseudo-blue noise shaderHow fast does walk-on-spheres converge?AoC 12: shortest path under constraintsKDE estimationPlot: Correlation heatmapPoisson Finish 2Poisson disk sampling functionsWoS with transportSimple and surprising sortLocal medianTime series topological subsamplingUnion-FindLevel set experiment 1Mean value coordinatesPoisson potential
Middle-square
World of squares (spherical)World of squaresLargest Inscribed SquareHello, PyWaveletsGeothmetic meandianHello, Reorder.jsGeometric MedianImage FFTTransport to a mapDisc TransportTP3: Power Diagram and Semi-Discrete Optimal TransportThe blue waveHello, genetic-jsSliced Optimal TransportDruidJSSelf-Organizing Maps meet DelaunayHello, polygon-clippingseedrandom, minimalWalk on Spheres 2Walk on SpheresHello, AutoencoderKaprekar’s numberVoronoiMap2DHello, ccwt.jsPolygon TriangulationQuantile.invert?Linear congruential generatorHue blurNeedle in a haystackMoving average blurApollo 11 implementation of trigonometric functions, by Margaret H. Hamilton (march 1969)2D curves intersectionThe 2D approximate Newton-Raphson methodInverting Lee’s Tetrahedral projectionLinde–Buzo–Gray stipplingMean shift clustering with kd-tree2D point distributionsShortest pathKahan SummationHello, delatinDijkstra’s algorithm in gpu.jsLloyd’s relaxation on a graphManhattan DiameterManhattan VoronoiMobility landscapes — an introductionDijkstra’s shortest-path treeH3 odditiesProtein MatrixConvex Spectral WeightsSort stuff by similarityKrigingDelaunay.findTrianglen-dimensions binning?Travelling with a self-organizing mapUMAP-o-MaticMNIST & UMAP-jsHello UMAP-jsMean shift clusteringLevenshtein transitionRd quasi-random sequencesAutomated label placement (countries)Phyllotaxis explainedMotionrugsPlanar hull (Andrew’s monotone chain algorithm)South Africa’s medial axisTravelling salesperson approximation with t-SNEDistance to shoreWorkerngraph: pagerank, louvain…t-SNE VoronoiCloud ContoursCircular function drawingKruskal MazeMyceliumTravelling salesperson approximation on the globe, with t-SNEtsne.jstsne.js & worker
Insert cell
Insert cell
Insert cell
function* middleSquare(x, n) {
const n_10 = 10 ** n;
const n_2_10 = 10 ** Math.floor(n / 2);
const seen = new Set();
while (!seen.has(x)) {
seen.add(x);
yield (x = Math.floor(((x * x) / n_2_10) % n_10));
}
}
Insert cell
Insert cell
Insert cell
Insert cell
middleSquare(seed, n)
Insert cell
[...middleSquare(seed, n)].length
Insert cell
Insert cell
good = worker`
${middleSquare}
const n = ${n};
let score = 0;
let count = 0;
do {
const seed = Math.floor(Math.random() * 10 ** n);
const seq = Float64Array.from(middleSquare(seed, n));
const l = seq.length;
if (l > score) {
score = l;
globalThis.postMessage({seed, score, seq});
}
} while (count++ < 100000);
`
Insert cell
Insert cell
Plot.rectY(good.seq, Plot.binX({ y: "count" }, { thresholds: 100 })).plot({
x: { tickFormat: "s" }
})
Insert cell
Insert cell
counts = worker`
${middleSquare}
const n = ${n};
const A = [];
do {
const seed = Math.floor(Math.random() * 10 ** n);
A.push([...middleSquare(seed, n)].length);
globalThis.postMessage(A);
} while (A.length < 10000)
`
Insert cell
Plot.rectY(
counts,
Plot.binX({ y: "count" }, { x: counts, thresholds: 100 })
).plot()
Insert cell
Insert cell
Insert cell
Insert cell
import { observeWorker as worker } from "@fil/worker"
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