# How to make a random number not random?

Need to on request were given a random number, but 20% to 80%.

For example, from the interval from 0 to 10, out of 100 calls, 20% will fall to 0-3, and 80% falls to 4-10.

Not asking for ready function, but maybe someone knows the algorithm for such a random number? Or an example in any language that he is already rewritten in python.
September 19th 19 at 12:17
September 19th 19 at 12:19
Solution
The first call to rand shows what "interest" gets the next number, and then twitches a second time rand with the necessary boundaries to obtain the number and boundaries depending on the first.

Regarding randomness-randomness, rand, in your case probably does not give a random (!!!) sequence.
Long read and tried to understand, and I think I understand what you mean. Now write and test your version. Thanks for the idea. - brend commented on September 19th 19 at 12:22
Ready generators with such properties, I do not know, but the idea of this "head" and not the fact that good. - tess.Simonis3 commented on September 19th 19 at 12:25
: your method worked. Thanks for the idea. It is simple in a forehead and searched. The solution with the test will be writing in response. Then unfortunately you can not insert photos. - brend commented on September 19th 19 at 12:28
September 19th 19 at 12:21
At the suggestion , did the following:

``````from random import randint
def rrand(n):
if randint(0,9) < n:
return randint(0,1)
return randint(2,9)``````

n - charge % ratio, in this case 2, i.e. 20%
(0,9) - ranges

Here is an example of 10 tests with 1000 calls to the function:

According to the results we see that approximately our conditions are met, we got ~20% some answers, and ~80% of the other. In my case, it suits me.
Well nice! - brend commented on September 19th 19 at 12:24

Find more questions by tags Programming