I have some statistics by age and I want to generate random values based on these statistics. Statistic.
I want to select ranges based on their probability, and within the range, select a random value using uniform distribution. For example, (25,35) - 37% and generate randomly... 33. I have code:
import numpy as np
import random
range_age = [list(range(12, 18)), list(range(18, 25)), list(range(25, 35)), list(range(35, 45)),
list(range(45, 55)), list(range(55, 70))]
age = random.choice(np.random.choice(range_age, p=[0.179, 0.257, 0.37, 0.109, 0.037, 0.048]))
print(age)
How can I get a value from a list with a uniform distribution? (Instead of this random.choice) Or maybe you can use another way to generate a value based on statistics?
Aucun commentaire:
Enregistrer un commentaire