Cloudflare uses a wall of lava lamps for some of their RNG needs
Math! Also, noise!
There are algorithms (a set of math steps) that make pseudo-random numbers. These usually involve large prime numbers, because those usually generate fewer repeating patterns.
A truly random number generator is similar to rolling dice: you use some source of randomness and convert it to a number. All electric circuits produce “noise” (which is often received radio waves and such that interfere with the circuits). Think of tuning a radio to a channel with nothing on it–you get “white noise”, which can be a good source of random information. Then all you need to do is convert that to a range of numbers, and you’re good to go.
These are fairly simplified explanations, so take them with a grain of salt, but they give the general idea.
Psudo random numbers come from a special set of mathematical equations which act as the basis for natural processes. These are known as nonlinear dynamic equations.
Their outputs feed back into their inputs. They show areas of high initial sensitivity where any tiny change in input totally changes the output over time. Finally, they often show areas of different cycling behavior. The branch of math which studies them is holomorphic dynamics.
The psudo-randomness of slightly different seed values generating wildly different outputs has to do sensitivity to initial conditions. This is a property of the paramater space structures in which those random number sequences cycles through. The ‘path’ of numbers that will be cycled through is determined by starting position and the geometric topology in the complex plane which the equation generates.
By graphing and iterating psudo random equations in the conplex plane, it generates infinitely complex geometric structures called julia sets which govern how algebraic numbers cycle through pseudorandom walks depending on initial seed values and equation used. These julia sets often are fractals with infinite complexity at its borders at all scales of precision.
Julia sets have a “stuff goes everywhere” property which is the the real magic of where sensitivity to initial conditions comes from. But now were getting deep into the weeds of math nerd territory.
Simply put, you put a random number in and it spits a more-or-less random number out, thanks to wierd properties that the higher dimensional fractal hyper structures generated by the equation in the complex plane have. Those lower dimensional random number cycles are embedded into the julia set structurally.
A big issue with psudo randoms is they will always give the same series numbers if you begin the equation with the same computationally finite seed values. You could the generated sequence of numbers to work back and find the seed values and equation used to generate them. This is a serious security concern when using them for cryptography. The amount of computational work it takes to work back is massive but its doable with modern quantum super computers.
The mechanics of pseudo random numbers comes from statistical combinatorics, nonlinear algebra,fractals, chaos theory, and sensitivity to initial conditions.
True random numbers come from directly measuring physical phenomenon with sufficient randomness in their mechanics.
Things like the decay of a radioactive isotope or lava lamp turbulence have built in randomness. There is no seed or way to generate the same sequence of motions or predicting when isotopes decay.
Turbulance for example has fractal properties in its energy distribution as well as random brownian motion adding up on the atomic scale. Radioactive half life has uncertainty principal built into it. These universal operations have true uncalculatable randomness thanks to entropy, the uncertainty principle, fractals, brownian motion, chaos theory, and sensitivitiy to initial conditions.
The physical universe is the most powerful computer there will ever be. It calculates with infinite decimal precision in its mixed mathematical, statistical, and physical operations. It uses real trancendental like pi numbers with infinite non-repeating decimals, and does its calculations at the speed of causality/light.
Our best super computers will never be infinitely powerful. Our numbers need to be finite and computable to work with them and understand them. The universe could not care less if its values are finitely computable or usable for human work.
So theres fundamental limits to how random we can get through artificial computer algorithm generation using computable numbers. True randomness through physical processes leverages the universes in built infinite precision and mechanical algorithms as a black box and just measures the output result.
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.
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.