Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forward-leaning random numbers' probability distribution

Say I'm pseudo-randomly picking a number from 1 to 50 every second for 100 seconds, and as time goes on the number picked is more likely to be greater. How could I structure such an algorithm?

For example: after 99 seconds the probability of choosing a number closer to 50 is much more likely than choosing a number closer to 1.

Or: the number picked after 10 seconds is more likely to be greater than the number picked after 9 seconds

like image 227
werdnanoslen Avatar asked Aug 12 '11 22:08

werdnanoslen


People also ask

How do you generate a random number from a given distribution?

Perhaps the most generic way to do so is called inverse transform sampling: Generate a uniform random number in [0, 1]. Run the quantile function (also known as the inverse CDF or the PPF) on the uniform random number. The result is a random number that fits the distribution.

What is the distribution of random data?

A random distribution is a set of random numbers that follow a certain probability density function. Probability Density Function: A function that describes a continuous probability. i.e. probability of all values in an array.

What are the types of probability distribution?

There are two types of probability distributions: Discrete probability distributions. Continuous probability distributions.

How do you find the distribution of a random variable?

The probability distribution for a discrete random variable X can be represented by a formula, a table, or a graph, which provides p(x) = P(X=x) for all x. The probability distribution for a discrete random variable assigns nonzero probabilities to only a countable number of distinct x values.


2 Answers

Pick any concave monotonic function like square root which maps 0 to 0 and 1 to 1. Generate a random number between [0,1], apply the function and then scretch [0,1] to the desired interval ([1,50]).

Now if you morph from the linear transformation f(x)=x to the mentioned transform function with for example a simple weighting you have the desired effect.

like image 90
Karoly Horvath Avatar answered Nov 24 '22 05:11

Karoly Horvath


I have a simple solution for you. Instead of rand(1, 50) (say this function generates uniformly random numbers 1..50) use this expression:

power(rand(1, power(50, exp)), 1/exp)

this will still give you all the numbers 1..50. For exp = 1, the distribution will be uniform. As you slightly increase exp (e.g. like 1.1 or so), the probability of getting larger numbers will increase. The higher the exp, the more it will increase towards 50.

So you can do e.g.:

factor = 1 /* finetune this for your needs */
for second = 0..100
    exp = 1 + (second / 100) * factor
    rand_num = power(rand(1, power(50, exp)), 1/exp)
endfor
like image 24
Tomas Avatar answered Nov 24 '22 03:11

Tomas