[Numpy-discussion] NumPy Histogram for Tentative NumPy Tutorial Questions
Wayne Watson
sierra_mtnview at sbcglobal.net
Thu Nov 26 14:44:47 EST 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)
pylab.show()
# 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)
pylab.show()
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?
--
Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
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