How to use python and scipy to get a poissio random variable? Wow..I installed scipy and per the docs I get No module named scipy.stats? I am on ubuntu 12.04. So......go figure
http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.poisson.html
ubuntu@ubuntu:~/Downloads$ sudo apt-get install python-scipy
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-scipy is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 482 not upgraded.
ubuntu@ubuntu:~/Downloads$ python
Python 2.7.3 (default, Apr 10 2013, 06:20:15)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy.stats import poisson
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scipy.stats
I think scipy is the way to go. Probably you have a simple namespace visibility problem. since stats is itself a module you first need to import it, then you can use functions from scipy.stats
import scipy
import scipy.stats
#now you can use
scipy.stats.poisson
#if you want it more accessible you could do what you did above
from scipy.stats import poisson
#then call poisson directly
poisson
pip install --upgrade --force-reinstall scipy
I accidentally caused this issue by naming one of my scipy test programs "scipy.py". Of course, this makes any "import scipy" in this directory import my test program, not the system library, in turn resulting in lots of errors like:
ImportError: No module named stats
It's embarrassing how long it took me to figure this out!
I had a similar issue with Python 3.4 on my Windows 7 machine. I had to update my scipy package 'pip install --upgrade scipy'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With