52.4k views
3 votes
What equation can I use to pick numbers 1-70 if they're picked randomly

User FanoFN
by
3.8k points

1 Answer

0 votes

9514 1404 393

Answer:

you cannot use an equation to pick random numbers

Explanation:

"Picked randomly" and "using an equation" are mutually exclusive. A random number cannot be predicted, so an equation cannot be used to generate it.

That being said, many programming languages make use of a "linear congruential generator" for generating random numbers. Such a generator generates a next number (x') from a previous number (x) using the equation ...

x' = (a·x +c) mod m

Numbers generated in this way are called "pseudo-random numbers." The sequence of generated numbers will repeat at some point, and the statistics of generated numbers may or may not be suitable for any given application. (For example, sequential numbers may tend to be correlated.) The distribution of numbers is inherently uniform, so if you need other distribution, you need to perform some math on what you get from a linear congruential generator. Methods are available for approximating about any kind of distribution you might want.

This is not the only "equation" that can be used, and is certainly not the best.

__

A variety of different values of a, c, m are used in generators of this type. Some are better than others at producing what looks like randomness. Here's a set of numbers you can try: (no claim is made regarding suitability for your purpose)

  • a = 1140671485
  • c = 12820163
  • m = 2^24 = 16777216

This will produce numbers in the range 0–16777215. To get numbers in the range of 1-70, you can map these to your range in any suitable fashion. For example, you could add 1 to the integer part of the result from division by 239675.

Below is a graph of the sorted output of 200 values in the range 1–70 from the generator described here. You can see the distribution is approximately linear, and that some values are missing while others show up more often than average. (You expect this with random numbers.) The seed for these numbers (first value of x) is 1337457.

__

There is a web site available that will produce random numbers to your specification, based on the background noise of the universe. They are truly random.

What equation can I use to pick numbers 1-70 if they're picked randomly-example-1
User Son Truong
by
3.3k points