Skip to content

Instantly share code, notes, and snippets.

@tophtucker
tophtucker / README.md
Last active November 4, 2022 18:22
Collapsing high-dimensional normal distributions

My friend Colin has been trying to give me a better intuition for higher dimensions. His first fun fact was that the volume of an n-dimensional hypersphere peaks somewhere around n=6 or so, I forget, and then approaches 0 as n approaches infinity. Damn! Meanwhile, of course the volume of a hypercube just diverges to infinity, as you'd expect. So if you inscribe a hypersphere in a hypercube, as dimension increases, more and more of the volume is in "the corners" — ultimately, almost all of it.

That's not what I'm trying to show here, it's just cool. This is somewhat different.

Colin also pointed out that, in a high-dimensional multivariate random normal distribution (with identity covariance matrix), all the mass ends up coming to be found in a sort of donut at some distance from the middle. There's very little mass in the middle. Of course the origin is still the mean/median/mode. The problem is that the middle is just so dang small, and there's SO MUCH SPACE as you go a little further out. So if you're jus

@tophtucker
tophtucker / README.md
Last active September 13, 2019 09:58
Pagerip

Pinch apart to split the viewport in two, so you can do parallel reading. Pinch together to recombine. Only tested on iPhone & iPad; should work on other multitouch devices?; doesn't do anything (or make any sense) on non-touch single-pointer mouse/trackpad devices, whatever we're calling that classic category these days. But you can see it demo'ed in this tweet.

WHY:

The Web is missing lenses and mirrors and such, I think — images! maps! — fundamental mechanics for getting various views on the same underlying content. We have the freedom to paint any pixel according to any arbitrary rule, and yet it's weirdly hard to . . . like, hold your place in a long document, as one would with a finger marking a page in a book as you skim ahead. Sometimes I highlight the last sentence I read with the mouse so it jumps out when I scroll back up, which is a nice near-unconscious hack that takes advantage of something I know about how document state work

@tophtucker
tophtucker / index.html
Last active November 4, 2022 18:23
Wiggly line (for Alan maybe? I forget)
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg {
overflow: visible;
}
path {
@tophtucker
tophtucker / README.md
Last active March 12, 2021 20:26
Swizzle

Swizzling! (Or pandas DataFrame "reshaping" / "pivoting" / "(un)stacking".)

Click and drag the i,j,k in the upper right to reorder. Refresh for random dimensions.

One can imagine more spreadsheety stuff, extending to 4D arrays and higher, and aggregating/slicing/collapsing/folding along different dimensions.

No, I'm not at all sure I'm using the term "swizzle" correctly. I don't understand matrices.

gistup
@tophtucker
tophtucker / README.md
Last active January 29, 2017 06:54
Transpose
@tophtucker
tophtucker / .block
Last active January 29, 2017 00:17
Rationals
height: 960
@tophtucker
tophtucker / .block
Last active November 4, 2022 18:23
CMYK
license: gpl-3.0
@tophtucker
tophtucker / .block
Last active January 15, 2017 23:44 — forked from mbostock/.block
CMYK Wave Motion
license: gpl-3.0
@tophtucker
tophtucker / .block
Last active April 26, 2019 14:50
Trump support vs. distance from major city
license: gpl-3.0