Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "check" if a function really gives a random result?

How can one be sure that a function is really random or as close to the notion as possible? Also, what is the distinction between random and pseudo-random? Finally, what algorithms/sources can be used to generate random numbers?

P.S: Also asking this because a MySQL statement using ORDER BY RAND() LIMIT 1 isn't giving convincing results.

like image 860
James P. Avatar asked Jun 22 '11 10:06

James P.


People also ask

How do you know if a function is random?

To test a function that returns random numbers you should call it many times and see how many times each number is returned. All that this tests is whether the distribution is rectangular - it doesn't test for (pseudo-)randomness at all.

How do you verify randomness?

Hypothesis: To test the run test of randomness, first set up the null and alternative hypothesis. In run test of randomness, null hypothesis assumes that the distributions of the two continuous populations are the same. The alternative hypothesis will be the opposite of the null hypothesis.

Are random functions really random?

Researchers typically use random numbers supplied by a computer, but these are generated by mathematical formulas – and so by definition cannot be truly random. In the 1970s, scientists discovered that a widely-used formula produced regularities in its 'random' numbers that undermined countless research studies.

Is random in python truly random?

The random number or data generated by Python's random module is not truly random; it is pseudo-random(it is PRNG), i.e., deterministic. The random module uses the seed value as a base to generate a random number. Use a random.


Video Answer


1 Answers

The thing about being random is that you can't tell if the return from a random function is random or not.

XKCD

...or...

Dilbert

Proper random uses something that can truly be random, such as white noise. Pseudo random numbers are generally calculated from mathematical formulae or precomputed tables. The Linear congruential generator is a popular method of generating them.

To get a real random number, you generally want to interface with an outside source where something has been generated organically. This is called a True Random Number Generator.

like image 176
alex Avatar answered Oct 22 '22 23:10

alex