pythonstatistics

Create random numbers with left skewed probability distribution


I would like to pick a number randomly between 1-100 such that the probability of getting numbers 60-100 is higher than 1-59.

I would like to have the probability to be a left-skewed distribution for numbers 1-100. That is to say, it has a long tail and a peak.

Something along the lines:

pers = np.arange(1,101,1)
prob = <left-skewed distribution>
number = np.random.choice(pers, 1, p=prob)

I do not know how to generate a left-skewed discrete probability function. Any ideas? Thanks!


Solution

  • Like you described, just make sure your skewed-distribution adds up to 1.0:

    pers = np.arange(1,101,1)
    
    # Make each of the last 41 elements 5x more likely
    prob = [1.0]*(len(pers)-41) + [5.0]*41
    
    # Normalising to 1.0
    prob /= np.sum(prob)
    
    number = np.random.choice(pers, 1, p=prob)