6 ms·
A brief history of random numbers (2018)
- gwbas1c 1y agoI've always wondered, if you started recording audio, can you treat the least significant bit as random? Perhaps as an alternative to a real hardware random number generator?
- arch_btw 1y agoYeah it would be fun to play with... I gotta think there are going to be some periodics in there that will be toggling the LSB. Like some hum from some device far away will be at the right tiny amplitude to toggle it in a predictable way. Also the ADC hardware could concievably get stuck. The whole system breaks because someone didn't set up their pulseaudio correctly? and what if you need 1TB of random data? With 48kHz audio you would be waiting 5000 years haha. 1MB is still more than a day
- tralarpa 1y ago> and what if you need 1TB of random data? With 48kHz audio you would be waiting 5000 years haha. 1MB is still more than a day I think you dropped the "k" in "kHz" in your calculations.
- butlike 1y agoPlease tell me if I'm off-base here, but something I always thought about and have been toying with is the notion that "there's no true random in this universe." From a particle physics perspective, as an observer in the electromagnetic spectrum, we're always observing through a reference frame based on the speed of light in relation to the observed object. Because it's always in reference to a constant, c, anything perceived at random can theoretically be measured if you had the position of the observer at the time of observation, right? Am I way off-base here?
- kryptiskt 1y agoAny fan of determinism would need to tackle quantum physics and what seems like unavoidable randomness in it (and there are such theories, but they offer little hope of getting around the randomness from our point of view, since they hide the order from us). The typical example of a random phenomena in nature is radioactive decay. You can't predict when any given nucleus will decay, only the probability that it will happen (which gives the half-life).
- butlike 1y agoFair enough. Thanks!
- glonq 1y agoFrom the title, I expected to see a list of recently-generated random numbers. I got a 27 yesterday.
- oniony 1y agoI just get 4 every single time.
- deleted 1y ago[deleted]
- jkhall81 1y agoI thought this was a proper article. It was a good read. Then I start looking around at the page and was like 'where the hell am I? This is a rust crate readme?!'
- SAYANG13 1y ago[flagged]
- nzeid 1y ago> So, just using any old LCG wasn't good enough, you had to use one made by someone with a PhD in mathematics. Donald Knuth shook his fist at the world and shouted "Hah! I told you so!", published a book on how to do it Right that most people didn't read, and then went back into his Fortress of Solitude to write TeX. Haaaaaaaaaaaaaaa, I believe every word of this.
- dollylambda 1y agoTalk about skipping a `1.0` release. Is anyone else scratching their heads about this? Here https://hg.sr.ht/~icefox/oorandom/rev/46ca789e6bb68cfc5d838ffc637871a9c8e35736 https://hg.sr.ht/~icefox/oorandom/rev/46ca789e6bb68cfc5d838f... the project jumps from a 0.1.0 release to 9.3.0.
- dollylambda 1y ago"The version number is inversely proportional to the likelihood that I will ever come back and do something that would require incrementing it." LOL
- lucasfcosta 1y agoThis is what I come to HN for.
- derbOac 1y agoIs there a good text on random number generation that someone on HN can recommend? I've read about various generators, pseudorandom and truly random, but those have always been scattered across various places, and I'm wondering if there's a good solid unified text on all of them, in terms of families of them and their underlying ideas, and their advantages and disadvantages.
- slybot 1y agohttps://www.pcg-random.org/posts/bounded-rands.html https://www.pcg-random.org/posts/bounded-rands.html
- buildbot 1y agoI did not realize xorshift no longer as favored! Permuted Congruential Generators seems very cool. https://en.wikipedia.org/wiki/Permuted_congruential_generator https://en.wikipedia.org/wiki/Permuted_congruential_generato...
- adgjlsfhk1 1y agoXorshift variations (specifically xoshiro256++ and friends) are still really good.
- ot 1y ago> Since nobody had figured out any downsides to PCG's yet, everyone shrugged and said "might as well just go with that then", and that is where, as of 2019, the art currently stands. The problem is solved, and life is good. I wonder who "everyone" was, I'm not aware of many high-profile projects adopting PCG as a default. As of 2025, several high-profile runtimes (including all the major browsers) use xorshift variants [1] Is there a list of users of PCG? [1] See Adoption section in https://prng.di.unimi.it/ https://prng.di.unimi.it/
- vlovich123 1y agoIt kind of doesn’t matter if there are users - there are people still stupidly using Mersenne Twister. The point is that PCG is better than xorshift and related in that family. That other high profile applications haven’t switched is besides the point that PCG is objectively better: > O'Neill proposes testing PRNGs by applying statistical tests to their reduced-size variants and determining the minimum number of internal state bits required to pass.[7] TestU01's BigCrush examines enough data to detect a period of 235, so even an ideal generator requires 36 bits of state to pass it. Some very poor generators can pass if given a large enough state;[8] passing despite a small state is a measure of an algorithm's quality, and shows how large a safety margin exists between that lower limit and the state size used in practical applications. PCG-RXS-M-XS (with 32-bit output) passes BigCrush with 36 bits of state (the minimum possible), PCG-XSH-RR (pcg32() above) requires 39, and PCG-XSH-RS (pcg32_fast() above) requires 49 bits of state. For comparison, xorshift*, one of the best of the alternatives, requires 40 bits of state,[5]: 19 and Mersenne twister fails despite 19937 bits of state.[9]
- adgjlsfhk1 1y agoIMO there's plenty of reason to use Xoshiro over PCG. the quality differences between the best xoshiro and pcg differences are minimal (especially because most languages use a 256 bit state since it makes it easier to split/jump without worrying about duplicate streams), and Xoshiro generators tend to be easier to SIMD for when you need lots of random numbers.
- 1y ago
- zkmon 1y agoRandomness is far more profound than it appears to be. Probably it doesn't even belong to the real (materialized) world.
- buildbot 1y agoHow so? I also find randomness profound but not sure what you mean but not belonging in the materialized world. Particle decay/Radiation is a pretty random process I believe?
- card_zero 1y agoPossibly connecting random events to time, which is not material.
- IAmBroom 1y agoThe transformation of a particle into two more basic particles is absolutely material.
- card_zero 1y agoSome confusion? I was saying "time is not material". In my conception time is made out of events, and the events are I suppose all material, and all have probabilities. So maybe time follows inevitably from matter. But I think it exists in its own right as a phenomenon that isn't material. There are such things. Knowledge is another one.
- IAmBroom 1y agoNoether's Theorem states that it is fundamental to our real world - or else the apparent, fundamental symmetries of our physics are wrong.
- olivia-banks 1y agoI love how this is written. A lot of things nowadays on this site, if only vaguely, make me think it was written in part by an LLM, but this didn’t fall into that category. Great read, bravo!
- camel-cdr 1y agoA history about random number generation isn't complete without mentioning George Marsaglias work. He is responsible for multiply-with-carry, xorshift (the original version), KISS (a high quality generator predating the mersene twister) , the Ziggurat algorithm, diehard Fun fact, one of the earliest methods for generating random mumbers, the middle square method, actually still passes all moderm statistical randomness test suites, if you hook up a weyl sequence to it: https://arxiv.org/abs/1704.00358 https://arxiv.org/abs/1704.00358 This, the middle square weyl sequence PRNG is my favoeite PRNG, because it's simple enough to implement from memory: uint64_t x, weyl; uint32_t msws(void) { x = x * x + (weyl += CONSTANT); return x = (x >> 32) | (x << 32); } You just take a number, square it, advace and add the weyl sequence to it amd finally swap the lower and upper bits, using the trucated result as the output. The CONSTANT is pretty much arbitrary, it just needs to be odd and not too regular. A good rule of thumb is to have no repeating or zero nibbles in each group of 4 bytes, e.g. 0xB5AD4ECEDA1CE2A9.
- LPisGood 1y agoThe Ziggurat algorithm is very important and widely used. There are some side channel vulnerabilities in differential privacy applications based on the details of this algorithm.
- avadodin 1y agoThat paper doesn't mention how many rounds it passed on the statistical tests, just that they tested 25000 seeds. They also don't definitely state a period but 2^64 with 192 or 384 bits of state is not that impressive. Furthermore, your version here uses only 128 bits so it is not clear to me that it is equivalent to the ones presented in the paper.
- camel-cdr 1y agomsws32() from the paper is the exact code I wrote above. The "s = 0xb5ad4eceda1ce2a9" is not part of the state, it's the CONSTANT. I've tested msws32 it passes TestU01s BigCrush and didn't fail in >=1 TB of PractRand (I stopped after that). A scaled down msws16 fails PractRand after 2 GB, a msws24() variant passes >=256 GB (I stopped after that). It's certainly not as good as more state of the art PRNGs like PCG, xoshiro, romu, sfc64, tylo64, but it is very simple and has quite high quality output, much better than any similarly simple to construct PRNG I know of.
- dswalter 1y agoRefreshing when technical writing has a sense of style. Read it and gain a gnawing sense of unease at how "good" things might really be at present!
- websku 1y agorandom numbers are not exactly random.
- nachox999 1y agonatural random numbers are not (exactly) random or artifical generated random numbers are not (exactly) random?
- Cold_Miserable 1y agoXorshift, LCM and hardware rdrand work just fine. PCG and Weyl are overkill.
- NoSalt 1y agoI dunno ... his saucy language made this very difficult to read.
- a-dub 1y agoi thought they were all built on the compression functions from secure hashes these days?
- tptacek 1y agoThat's how secure random number generators work. Those are suitable for almost all purposes except for simulations, where you're tapping the RNG so often that its performance really matters and demands more than the cycles/bytes of even optimized cryptography gets you.
- wglb 1y agoPlus with a simulation, you may want to replicate runs.
- some_furry 1y agoYou can use a seeded PRNG (e.g., AES-CTR-DRBG) and get replication while still preserving cryptographic security.
- jcynix 1y agoIf you are so inclined, you can build your own random number generator in hardware, which uses a Geiger counter: https://www.instructables.com/Arduino-True-Random-Number-Generator/ https://www.instructables.com/Arduino-True-Random-Number-Gen...
- PantaloonFlames 1y agoThis was entertaining and informative, the best kind of info. But one puzzle remains - why did the author keep mentioning slide rules as a tool that would reveal the non-randomness of some number series ? I don’t get that part.
- dcminter 1y agoI took it as being a tongue-in-cheek way of saying "mathematicians."
- ChrisSD 1y agoThey're using slide rule users as a stand-in for serious mathematician as opposed to people who incidentally use mathematics. It makes some sense in historical context but becomes a bit anachronistic after the invention of electronic calculators.
- ordu 1y agoSlide-rule is a sort of "trope". If you need to signal to readers or your book or watchers of your movie that some character has STEM education, you give them a slide-rule. There are other ways to do this, you can make them wear white coats. White coat is more popular though, if the author used white coats, I'm sure you'd be able to get it.