If you're using your camera for random numbers, make sure you're talking to the raw device directly, and not getting an image that's been heavily massaged, like with an iPhone's HDR / Deep Fusion cameras. And use a lens cap instead of pointing it at a Lava Lamp, because that's patented!

https://www.wired.com/2003/08/random/

>Now Noll is working with Cooper on an improved RNG called LavaRnd (which debuted in May at www.lavarnd.org). The new process replaces the lava lamps with a more Zen-like source of entropy: a webcam with its lens cap on. The chaotic thermal "noise" emitted by the webcam is digitized and put through a hash algorithm that churns the number set, stripping unwanted sections of predictability. The result is a cryptographically strong sequence of numbers, ready for use in the real world. And because the new service is open source, patent-free, and license-free, anyone will be able to cheaply build and operate a LavaRnd server and receive the precious commodity free of charge - a random act of kindness.

Careful with that lower bit, Eugene:

The pseudo-random number generator in the C library was really bad in earlier versions of Unix. It still is bad, and it used to be patronizingly called "simple", but now the title of the OpenBSD manual page finally recognizes rand for what it is:

https://man.openbsd.org/rand

NAME

rand, rand_r, srand, srand_deterministic — bad pseudo-random number generator

It was so bad in SunOS 4.1.3 that the rand(3) manual NOTES section coyly understated: "The spectral properties of rand() leave a great deal to be desired."

So bad that the lower bit would actually alternate between 0 and 1 every time you called it, so if you used "rand() & 1" to flip a coin, it would flip perfectly back and forth between heads and tails forever.

https://www.freebsd.org/cgi/man.cgi?query=rand&sektion=3&man...

NOTES

The spectral properties of rand() leave a great deal to be desired.
drand48(3) and random(3) provide much better, though more elaborate,
random-number generators.

BUGS

The low bits of the numbers generated are not very random; use the mid-
dle bits. In particular the lowest bit alternates between 0 and 1.

http://cpp.indi.frih.net/blog/2014/12/the-bell-has-tolled-fo...

>Nothing about rand()‘s behaviour is required.
rand() could legally return the same value over and over every time you call it. It could have a period in the single digits; or return alternating odd and even numbers (and one implementation actually did this!). There have been some implementations that are legendarily bad. The C11 standard actually says some implementations are known to produce sequences with distressingly non-random low-order bits, and advises against using it for serious purposes.

Bash and other shells build on top of that badness, and manage to make the bad randomness infinitesimally worse, by not allowing repeated random numbers, for some inexplicable reason. (See: Cargo Cult Programming)

https://nullprogram.com/blog/2018/12/25/

>Like Bash, repeated values are not allowed. I suspect one shell got this idea from the other.

do {
cur = (rand() >> rand_shift) & RANDMASK;
} while (cur == last);

>Who came up with this strange idea first?

https://en.wikipedia.org/wiki/Cargo_cult_programming