Pseudo-Random vs. True Random
boallen.com
boallen.com
Bad PRGs can be ruled out by tests like the one in the article, that is, showing that the exhibit some regularities that would be unlikely to get from a truly random source. An infamous example is RANDU [1], whose output is concentrated on low-dimensional subsets.
Smart people have put together batteries of statistical tests to assess the quality of PRG, the most famous being the Diehard test [2]. The idea is that if a PRG passes all the tests it is indistinguishable from a truly random source for all practical purposes.
Good generators such as the widely used Mersenne Twister pass most of its tests. There are even better generators that pass more tests, such as Marsaglia's Xorshift [3], which is faster and simpler than the Mersenne Twister, and surprisingly not very well known.
For anyone interested in PRGs, I strongly recommend reading Marsaglia's original paper [4], it is a good example of how to design a principled PRG and it just requires some elementary linear algebra on finite fields.
[1] http://en.wikipedia.org/wiki/RANDU
[2] http://en.wikipedia.org/wiki/Diehard_tests
RNGs have two primary functions: to provide statistically random values (for simulations, say) and to provide unpredictable values (mostly for crypto). These are different goals, and many RNGs are good at one but not the other. That's why we have both RNGs and Crypto RNGs.
Like many good RNGs for simulation, Mersenne Twister is not, and never has been, a Crypto RNG. It is explicitly in the first category.
I think a better approach is another recommended by Marsaglia: take a few different RNGs working on different principles, and just combine them by (say) adding them up.
Or, of course, just use something like the Mersenne Twister, which is more complicated than (e.g.) Marsaglia's KISS but there are enough good implementations out there that it doesn't really matter.
However, every so often I get a bug report professing some bias of the RNG. Turns out, people want the numbers to be not random but uniformly distributed even over small sample sizes of about 10 to 20 dice rolls. If the same number comes up three times in ten D20 rolls, they assume it must be a bug. The same happens with physical dice, by the way, I've seen players discard "unlucky" dice like that.
I believe they fixed it by changing the odds every time a track was played so it would seem to be making a more random selection, although technically it is now less random.
edit: similar to how some players generate a random playlist (every track on listed once, random order). Then on loop, either create an entirely new list, or simply loop.
I always thought this was by design: the "shuffle" algorithm wasn't designed to be random, but would instead occasionally group songs from the same artist or genre together (and/or favor songs w/ higher play counts_ - i.e. maintain a "theme" for a couple of songs before changing to something different)
I can't find any supporting evidence for this, however, and a lot of the discussions around their algorithm are hearsay.
http://en.wikipedia.org/wiki/RdRand
Pretty cool in my opinion; at least for applications where you don't need to repeat the same set of numbers.
For more check the "performance" section of this article
http://software.intel.com/en-us/articles/intel-digital-rando...
Note: if you need more than 500MB/s you can uses RDRAND (or RDSEED in Broadwell, when it comes out) to seed a PRNG. I was doing this at first, but the performance of the system didn't improve enough for it to be worth the added complexity.
And if you want to access it in linux from C you can either:
* Use inline assembly, just be sure to check the Zero flag after calling RDRAND, because if RDRAND fails (you're exceeding the 500MB/s) the zero flag isn't set, so you have to just keep calling RDRAND until it is.
* Use intrinsics (easier, immintrin.h), here's how I did it in my program (bug reports welcome, I'm only a freshman in college who had lots of free time and a fascination with fractals)
https://github.com/aarongolliver/FractalFlameMicahTaylorEdit...
http://software.intel.com/sites/products/documentation/studi...
I wrote an x86-64 asm impl as part of my lightweight Java crypto library (https://github.com/wg/crypto) would be easy to drop into any C program: https://github.com/wg/crypto/blob/master/src/main/asm/rdrand...
Intel released an open source library too, though in tests my asm impl was faster ;-) http://software.intel.com/en-us/tags/20757
The only reason there is a perceivable diference (in the presence of patterns) is that rand() is not very solid (it's optimised for speed, they recommend mt_rand() where a stronger generator is needed, and you can still do much better).
PHP's mt_srand is a Mersenne Twister, which is pretty good http://en.wikipedia.org/wiki/Mersenne_twister
Still, tries to sell "pseudo" vs "true" as if this image showed the difference.
Probably because it was interesting enough to stand out against the NSA/PRISM articles that have dominated the front page for the past few days.
Also, was the term 'n00bishness' necessary? I don't see any cause for attacking the author.
I guess I was wrong.
In this paper we consider the problem of efficiently locating
cryptographic keys hidden in gigabytes of data, such as the
complete file system of a typical PC. We describe efficient
algebraic attacks which can locate secret RSA keys in long
bit strings, and more general statistical attacks which
can find arbitrary cryptographic keys embedded in large
programs. These techniques can be used to apply lunchtime
attacks on signature keys used by financial institutes, or
to defeat authenticode type mechanisms in software packages.
Keywords: Cryptanalysis, lunchtime attacks, RSA, authenticode, key hiding.
[1 http://www.cs.jhu.edu/~astubble/600.412/s-c-papers/keys2.pdfhttp://cod.ifies.com/2008/05/php-rand01-on-windows-openssl-r...
I'm not a mathematician or computer programmer but wouldn't a TRNG require infinite memory, infinite storage, infinite time to generate etc.? One number generated may be 2 but the next number may be negative infinity.
I work in a casino as a slot tech and sometimes even though I know it's not true some patrons can almost convince you there are patterns.
Here is some history of random.org http://www.random.org/history/
and the wiki page http://en.wikipedia.org/wiki/Random.org
the wiki page for atmospheric noise briefly discusses it's applications to "high quality" RNG http://en.wikipedia.org/wiki/Atmospheric_noise
Unfortunately, the source code to the RNG is close-source, and they say they aren't going to release it. But my guess is they use that random noise as a seed to a PRNG. Their FAQ has quite a lot of information though: http://www.random.org/faq/#Q1.2
What are you talking about here? Generating random Real numbers or something? First off you'd have to define a distribution of some sort or your goal is meaningless...but throw all that out. It provides random the sensible way, one bit at a time. Interpret that bit however you want. Memory requirements: zero (or maybe O(1) depending on design). Time requirement: O(n) where n is the amount of entropy you desire.
I want random integers with no limit to the size returned, a truly random number and by that I mean a true random integer without any limitation in size.
Really I guess I'm trying to grasp how a true random anything could exist or more to the point how a person could make a device or even be able to know if a random number or anything has been returned as a result.
I may be misunderstanding you, but true randomness doesn't mean 'a distribution that's non-zero over the whole integers' - those are orthogonal concepts. You can have a TRNG that gives you a random choice from just {0,1} - the size of the distribution isn't what makes it a TRNG, that just determines how much entropy you need.
(And a uniform distribution over the integers is impossibly no matter how good your RNG is, as it's mathematically undefinable).
If you ask me, it is look pretty random.
(sorry for this)
https://en.wikipedia.org/wiki/Linear_congruential_generator#...
using this:https://gist.github.com/kennethrapp/198e419d1b620cddbc7d which should work a lot better in linux, but I haven't tested it with the image thing yet so who knows?
Currently I am using something like
r = (n*very_big_number)+seed
Pretty good? It has been known for decades that it is pretty bad.