1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
import numpy, csv
def echantillon_sexe():
panel_sexe = {'Homme':0.5,'Femme':0.5}
res = numpy.random.choice(list(panel_sexe.keys()),1,p=list(panel_sexe.values()))
return res
def echantillon_age():
choix_age = [10,20,30,40,50,60]
probabilite_age = [0.1, 0.2, 0.3,0.1,0.2,0.1]
res = numpy.random.choice(choix_age,1,p=probabilite_age)
return res
def echantillon_parcours():
choix_parcours = ['Jaune','Orange','Rouge','Noir']
probabilite_parcours = [0.25,0.25,0.25,0.25]
res = numpy.random.choice(choix_parcours,1,p=probabilite_parcours)
return res
for x in range(10):
visite=[echantillon_sexe(), echantillon_age(), echantillon_parcours()]
with open("import_v2.csv", "a") as csv_file:
csv_app = csv.writer(csv_file, dialect='excel')
csv_app.writerow(visite) |
Partager