Published
Edited
Mar 11, 2021
7 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 potentialMiddle-squareWorld of squares (spherical)World of squaresLargest Inscribed SquareHello, PyWavelets
Geothmetic meandian
Hello, 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
A = [1, 1, 2, 3, 5]
Insert cell
d3.gmdn(A)
Insert cell
Insert cell
d3.gmean(A)
Insert cell
Insert cell
d3.agmean(A)
Insert cell
Insert cell
d3.mean(A)
Insert cell
d3.median(A)
Insert cell
Insert cell
B = Float64Array.from({ length: 1e6 }, Math.random)
Insert cell
d3.gmdn(B)
Insert cell
d3.gmean(B)
Insert cell
d3.gmean([-1, -4]) // geometric mean of negative numbers, why not. But the numbers should all be of the same sign for this to have any kind of meaning
Insert cell
Insert cell
d3 = {
const d3 = await require("d3-array@2");

d3.gmean = function(data, value = d => d) {
const r = 64;
const K = 2 ** r;
const K1 = 2 ** -r;
let p = 1; // product
let n = 0; // count
let s = 1; // sign
let k = 0; // track exponent to prevent under/overflows
for (let i = 0; i < data.length; i++) {
const v = value(data[i]);
if (+v === +v) {
n++;
s = Math.sign(v);
if (s === 0) return 0;
p *= Math.abs(v);
while (p > K) (p *= K1), ++k;
while (p < K1) (p *= K), --k;
}
}
return n ? s * 2 ** ((Math.log2(p) + k * r) / n) : NaN;
};

d3.agmean = function(data, value = d => d) {
const step = a => [d3.mean(a), d3.gmean(a)];
let a = step(Array.from(data, value).filter(d => +d === +d));
while (Math.abs(a[1] - a[0]) > 1e-16) a = step(a);
return a[0];
};

d3.gmdn = function(data, value = d => d) {
const step = a => [d3.mean(a), d3.gmean(a), d3.median(a)];
let a = step(Array.from(data, value).filter(d => +d === +d));
while (Math.abs(a[1] - a[0]) > 1e-16) a = step(a);
return a[0];
};

return d3;
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more