#!/usr/bin/env python # -*- coding: utf-8 -*- from random import * # cf. documentation cf http://docs.python.org/library/random.html import numpy as np import matplotlib.pyplot as plt # http://matplotlib.sourceforge.net/api/pyplot_api.html#module-matplotlib.pyplot import matplotlib.mlab as mlab # http://matplotlib.sourceforge.net/api/mlab_api.html#module-matplotlib.mlab #seed('ma chaîne personnelle') # reproducible initialization seed() rval = [] for j in range(100000): rval.append(randint(0,99)) # append to the list a random (integer) number between 0 and 99 # print rval # uncomment just to see the list of random numbers # analysis - histogram - see http://matplotlib.sourceforge.net/examples/api/histogram_demo.html # http://fr.wikipedia.org/wiki/Histogramme xh = np.array(rval) # see http://www.scipy.org/Cookbook/BuildingArrays transforme une liste en un tableau numérique de Numpy # print(xh) fig = plt.figure() ax = fig.add_subplot(111) n, bins, patches = ax.hist(xh, 50, facecolor='green', alpha=0.75) print(n) # les nombres d'occurences par classe print(bins) # les classes, de largeur identique # modifier le nombre de nombres générés, les nombres de classes-bins, plt.show()