I have pylab and I want to plot a histogram of the following :
Basically I generate a random integer between 0 and 1.0 about 10,000 times and then I want to arrange each integer into a separate bin of the histogram so I can see on the histogram how many times each integer has been generated.

This is the coding I have so far:

from numpy import zeros , random , arange
import pylab
from pylab import bar

m= zeros (10 ,int)
for i in range (10000):
    x= random . randint(10)
if 0.0 <=x and x <0.1: m [0]=m [0]+1
if 0.1 <=x and x <0.2: m [1]=m [1]+1
if 0.2 <=x and x <0.3: m [2]=m [2]+1
if 0.3 <=x and x <0.4: m [3]=m [3]+1
if 0.4 <=x and x <0.5: m [4]=m [4]+1
if 0.5 <=x and x <0.6: m [5]=m [5]+1
if 0.6 <=x and x <0.7: m [6]=m [6]+1
if 0.7 <=x and x <0.8: m [7]=m [7]+1
if 0.8 <=x and x <0.9: m [8]=m [8]+1
if 0.9 <=x and x <1.0: m [9]=m [9]+1

pylab.plot(bar(arange (0 ,1 ,0.1) ,m, width =0.1))

thanks for helping!

5 Years
Discussion Span
Last Post by Gribouillis
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.