[Numpy-discussion] NumPy Histogram for Tentative NumPy Tutorial Questions

Wayne Watson sierra_mtnview@sbcglobal....
Thu Nov 26 13:44:47 CST 2009

I decided to try some example code from Subject.

import numpy
import pylab
# Build a vector of 10000 normal deviates with variance 0.5^2 and mean 2
mu, sigma = 2, 0.5
v = numpy.random.normal(mu,sigma,10000)
# Plot a normalized histogram with 50 bins
pylab.hist(v, bins=50, normed=1)       # matplotlib version (plot)
# Compute the histogram with numpy and then plot it
(n, bins) = numpy.histogram(v, bins=50, normed=1)  # NumPy version (no plot)
pylab.plot(.5*(bins[1:]+bins[:-1]), n)

After the histogram is displayed how do I get to the plot?  
Where is histogram described in some detail? Normalized? 
The histogram x-axis goes from 0 to 4.5. How does that happen? 
Is v is two dimensional? What if it's one dimensional?


                   350 350 350 350 350 350 350 350 350 350
                     Make the number famous. See 350.org
            The major event has passed, but keep the number alive.
                    Web Page: <www.speckledwithstars.net/>

More information about the NumPy-Discussion mailing list