Thanks for the suggestion, Chris, but I solved my problem an even simpler way:
Apparently, Linux created a "file" (and I use that term loosely) in /dev/urandom for this very purpose. It technically has a size of zero bytes, but reading from it produces binary data directly from the machine's entropy pool which is fed by the TrueRNG2 device as well as other processes built into Linux. Essentially, you can acquire true random numbers (if you have a hardware RNG) in IDL by reading from this file.
I initially tried using read_binary(1,data_type=1,data_dims=4) to read four bytes from the file and convert them into an unsigned float between 0 and 1, but I immediately got the message:
% READ_BINARY: The file to be read has zero length.
IDL was a little too smart for its own good, not realizing that the "file" is a link to the machine's entropy pool, and that the filesize is practially infinite since the pool replenishes itself as it is used. Unfortunately, IDL sees that the filesize is zero and doesn't even try to read it. Java and C don't seem to have this problem, though.
The second thing I tried was readu,1,randomBytes, which worked fine. File I/O is usually the least efficient part of a program, but I think reading from /dev/urandom is the best option.
--Carter
|