canine's cogent cognizances

home / New tab page, except math

published August 10, 2023 in math, programming post thumbnail

how it works

I adore Wikipedia’s random page capability – frantically hitting next at 3 AM to learn about a rural county or plant species is among my highest pleasures. I would redirect my new tab page, which I open every five minutes in lockstep with closing Hacker News, to Special:Random, but the problem is that these pages are very rarely math-related.

Instead of using a random forest of support vector machines like a pro would to determine semantic distance from Mathematics™️, I just downloaded Wikipedia’s category links & page info and wrote a low-performance C++ script to BFS over the math category. If there are (improbably) no bugs in my code, you can apparently reach almost a million pages by taking category links from math (for reference, there are ~59 million total). After a bit of trimming and shuffling Wikipedia’s articles with the paltry quantities from Encyclopedia of Mathematics and Art of Problem Solving, we end up with ~ 5 MB of 32-bit MediaWiki page ids, which are then randomly indexed by JS in the extension page.

Since pages closer to the beginning (BFS, remember?) are more relevant, I used Math.random()*Math.random()*length to skew the random function towards 0 (the cumulative distribution function is left as an exercise for the reader). The next function roughly takes the current index in the dump of article IDs mod 2671 and multiplies it by 539, a generator of the multiplicative group (when it returns to 1, we move to the next 2670-sized block). So, the longer you use this, the worse the quality gets.

how it looks

Look at that big, beautiful upper margin.

screenshot

download

Open this CRX (may not download for security reasons, in which case use wget or try below…) / drag and drop onto extensions page in your favorite compatible browser.

Here’s also a zip with ungodly source code that can be loaded unpacked.

You might be, like, the only other user of my insane invention. In any case, you should probably click random until you get a passably mathematical page; next will be called for each new tab you open.