I am looking for a distribution or rather a function that returns an integer in a specific range with decreasing probability the higher the number.
Lets say the range is from 1 to 5.
85% of the time the function should return 1
8% of the time the function should return 2
4% of the time the function should return 3
2% of the time the function should return 4
1% of the time the function should return 5
Additionally it would be great if the probabilities are according to a set distribution say normal distributed or exponentially distributed.
What would a function like this look like?
Try:
sample(xx,1) will return values by the given distribution. For more samples at a time:
You can check the distribution by:
Use
where for the probabilities you could use something like
or make use of the standard normal distribution
Edit For your specific example use
Not very efficient, and assumes that you can make sure that the cumsum adds up to 1.