Need help?
<- Back

Comments (62)

  • camel-cdr
    A 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, diehardFun 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.00358This, 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.
  • ot
    > 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/
  • jkhall81
    I 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?!'
  • PantaloonFlames
    This 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.
  • derbOac
    Is 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.
  • dollylambda
    Talk about skipping a `1.0` release. Is anyone else scratching their heads about this? Here https://hg.sr.ht/~icefox/oorandom/rev/46ca789e6bb68cfc5d838f... the project jumps from a 0.1.0 release to 9.3.0.
  • glonq
    From the title, I expected to see a list of recently-generated random numbers.I got a 27 yesterday.
  • olivia-banks
    I 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!
  • dswalter
    Refreshing 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!
  • jcynix
    If 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-Gen...
  • lucasfcosta
    This is what I come to HN for.
  • buildbot
    I did not realize xorshift no longer as favored! Permuted Congruential Generators seems very cool. https://en.wikipedia.org/wiki/Permuted_congruential_generato...
  • gwbas1c
    I'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?
  • a-dub
    i thought they were all built on the compression functions from secure hashes these days?
  • nzeid
    > 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.
  • Cold_Miserable
    Xorshift, LCM and hardware rdrand work just fine. PCG and Weyl are overkill.
  • NoSalt
    I dunno ... his saucy language made this very difficult to read.
  • butlike
    Please 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?
  • SAYANG13
    [flagged]
  • websku
    random numbers are not exactly random.
  • zkmon
    Randomness is far more profound than it appears to be. Probably it doesn't even belong to the real (materialized) world.