• paw@feddit.org
    link
    fedilink
    English
    arrow-up
    10
    ·
    edit-2
    1 month ago

    From my opinion it is more computer science sorcery than math sorcery.

    For true random generation you usually need some specialized hardware for it, that uses sone natural source of random. One could use the decay of a radioactive material as such a source or the noise one can get from audio input. Unfortunately, I don’t know what actual hardware uses.

    For pseudo random generation, you usually use a seed (ideally a true random value or something with a high entropy) which you feed into an algorithm like Linear Congruental Generator (LCG) or Mersenne Twister (there are lots of algorithms).

    One further important note: Tge use case forvwhich you need random numbers is important. A video game could accept a random number generator with “lower” quality while a cryptographic algorithm always needs a cryptographic secure random number generator (don’t forget: “don’t roll your own crypto”).

    Finally there are quasi randim number generators, however this name is very misleading. The mathematical correct term is low discrepancy sequence. There are not random at all but can be used and have useful properties in some settungs where pseudo random number generators can be used. Never in a cryptographic algorithm, though.

    • Treczoks@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      1 month ago

      An interesting source of randomness is using a diode “in reverse”. Randomly, a few electrons pass through, which can be amplified and measured. One uses a 2^n number of such constructs and XORs the results to get a random bit.

    • bulwark@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 month ago

      Great write up, now I have to google what a Meraenne Twister is. To use audio input noise as a random number gen I would just hook it up to a pressision digital db meter but I’m guessing the software implementation is a little more practical.

      • paw@feddit.org
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        1 month ago

        A software solution usually can create “random” faster, with the drawback that its not actual random

        The Mersenne Twister was a famous pseudo random number generator when I wrote my diploma thesis in 2009. Today, afaik, PCG (Permuted Congrentual Generator) are better.

    • paw@feddit.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      1 month ago

      Another tidbit: Operating systems (like Linux) usually provide a possibility to get entropy (ideally used as seed). Linux for example has /dev/urandom beyond others. Afaik, it uses the time between subsequent accesses to the hdd as one of the sources used to create the entropy.