I am creating a mock of sales data. One of the columns is salesperson_id where each id can occur more than once (a salesperson can have multiple sales). I want to generate this column in such a way that if I create a chart of distribution of sale count (not total sales) per salesperson_id, it would be a normal curve.

Let's say I have an array of unique salesperson_id called salespersons, I want to generate n number of records. For example, I have 6 salespersons and I want to generate total of 14 records. This would be the distribution of their counts:

id  count
A   1
B   2
C   4
D   4
E   2
F   1

If arranged in a bar chart, this would look like a normal distribution. I also need some way to control the 'flatness' of the chart.


1 Answer 1


Here is one way to do it:

from collections import Counter

from numpy.random import binomial

# Generate mock sales data by randomly sampling if a salesperson makes a sale  
p = 0.5 # Control "flatness" of distribution
n_records = 14
salesperson_id = binomial(n=100, p=p, size=n_records).tolist() # Binomial is a reasonable approximation for a discrete normal distribution
count_per_salesperson = Counter(salesperson_id)
id, count = zip(*count_per_salesperson.items())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.