Creating an offset bell curve

982 Views Asked by At

This is half programming and half math, but I need the math portion answered as I'm no good at it.

I have a list of 10 objects and am randomly selecting and object from that list. I need the "average" of that list to be chosen most often, but the "average" is the 6th item of the list. I need my probabilities to stay the same, but to be offset by +1. I can't just add 1 however, as that will cause an error if it attempts to choose the last object in the list +1 since it won't exist.

My current method is simply picking a random number from 0 (first index of array) through 9 three times, then dividing the result by 3. The probabilities are exactly as I'd like it, but obviously I'm getting the 5th object the most often instead of the 6th.

Thanks in advance for the answers, and if this is insanely simple I apologize for my horrendous math skills.

1

There are 1 best solutions below

4
On BEST ANSWER

Here's a distribution over those numbers that has an expected value of $6$:

  • Probability of a number less than 9: $\frac2{30}$
  • Probability of 9: $0.4$

I will leave it to you to verify that the average will in fact be 6. To implement this distribution, do the following:

n = (uniform random number from 0 to 1)
if n < 0.4
    return 9
else
    return uniform random number from 1,2,...,8

If you'd like a distribution in which 6 is the average and the most common, you can have a binomial distribution with $n=9$ and $p=\frac69=\frac2/3$. To program this distribution, you could do the following:

k = 0
for i = 1 to 9
    n = (uniform random number from 0 to 1)
    if n < 0.66
        k = k+1
return k