[Tutor] What is random.triangular() used for
Richard D. Moores
rdmoores at gmail.com
Sun Oct 24 22:57:51 CEST 2010
On Sun, Oct 24, 2010 at 13:29, Emile van Sebille <emile at fenx.com> wrote:
> From people who would know found at
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.triangular.html
>
>
> """The triangular distribution is often used in ill-defined problems where
> the underlying distribution is not known, but some knowledge of the limits
> and mode exists. Often it is used in simulations."""
Emile,
from the source code link on that page, I got
# Draw values from the distribution and plot the histogram:
import matplotlib.pyplot as plt
h = plt.hist(np.random.triangular(-3, 0, 8, 100000), bins=200,
normed=True)
plt.show()
Which when I run it I get
Traceback (most recent call last):
File "c:\P26Working\untitled-8.py", line 2, in <module>
h = plt.hist(np.random.triangular(-3, 0, 8, 100000), bins=200, normed=True)
NameError: name 'np' is not defined
Process terminated with an exit code of 1
The import goes OK:
>>> import matplotlib.pyplot as plt
>>>
and apparently I have numpy, if that's relevant:
>>> import numpy
>>>
but where do I get np?
Dick
More information about the Tutor
mailing list