読者です 読者をやめる 読者になる 読者になる

MCMCのPythonライブラリ

macbook air

(1)emcee
(2)emcee test
(3)nose
(4)Cython
(5)triangle_plot
(6)astropy
(7)scikit-learn
(8)astroML
(9)healpy
(10)pymc


(1)emcee install

#air の場合、 pip ではうまくいかなかった。
#mini はpipでOK

$ easy_install emcee

Searching for emcee
Reading http://pypi.python.org/simple/emcee/
Best match: emcee 2.1.0
Downloading https://pypi.python.org/packages/source/e/emcee/emcee-2.1.0.tar.gz#md5=c6b6fad05c824d40671d4a4fc58dfff7
Processing emcee-2.1.0.tar.gz
Writing /var/folders/rp/pl6_r3nd4jx77n_41w_wxv_c0000gn/T/easy_install-7Pi0Us/emcee-2.1.0/setup.cfg
Running emcee-2.1.0/setup.py -q bdist_egg --dist-dir /var/folders/rp/pl6_r3nd4jx77n_41w_wxv_c0000gn/T/easy_install-7Pi0Us/emcee-2.1.0/egg-dist-tmp-z_yyFt
zip_safe flag not set; analyzing archive contents...
Adding emcee 2.1.0 to easy-install.pth file

Installed /Users/user_name_of_this_mac/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/emcee-2.1.0-py2.7.egg
Processing dependencies for emcee
Finished processing dependencies for emcee

(2) test installation

$ python -c 'import emcee; emcee.test()'
Starting tests...
test_blobs ...
Passed.
test_ensemble ...
Passed.
test_inf_nan_params ...
Passed.
test_mh ...
Passed.
test_nan_lnprob ...
Passed.
test_parallel ...
Passed.
test_pt_sampler ...
[[ 4.28078961 9.65907666 12.04358703 2.87660849 7.82525845]
[ 3.2170057 4.24150198 5.38886129 2.57120086 3.5628032 ]
[ 3.34190318 3.93665869 0.82218183 2.12615653 2.49409284]
[ 2.96794288 4.44072437 3.32023843 1.41856222 2.0569162 ]
[ 3.61527134 5.3512537 4.55853738 2.75207078 3.02549049]
[ 3.95276797 6.1557117 4.38194265 3.01447094 3.24526784]
[ 3.96019439 6.18795309 4.57944292 3.06475761 3.37076447]
[ 4.11819964 5.7659697 4.8562809 3.0359267 3.32589204]
[ 3.85603363 5.8957338 4.66856969 2.73020252 3.26294585]
[ 3.99426772 5.59603551 4.77616469 2.71490972 3.06735538]
[ 3.84855889 5.30711848 4.39331468 2.63502553 3.03036884]
[ 3.72773645 5.31566673 4.29787118 2.68011324 3.30029418]
[ 3.70281773 5.21921852 4.31161499 2.54182746 3.18707777]
[ 3.51953548 5.44804836 4.34200003 2.43029784 3.21089521]
[ 3.52115997 5.57011287 4.22717807 2.33530092 3.01453834]
[ 3.53066543 5.59681081 4.16195481 2.32190219 2.96314379]
[ 3.61405652 5.67793786 4.54752642 2.36962106 2.96819806]
[ 3.73036245 5.69646144 4.49372029 2.44394668 2.91694628]
[ 3.51842425 5.69187972 4.84872206 2.24377814 3.20128908]
[ 3.55529756 6.06242817 4.92321959 2.36286834 3.41771155]]
Passed.
0 tests failed


(3)ついでにnose

$ easy_install nose

 

(4)Cython
$ easy_install cython

(5)triangle_plot
$ pip install triangle_plot

(6)astropy
$ pip install --no-deps astropy


(7)scikit-learn
$ pip install -U numpy scipy scikit-learn

(8)astroML
$ pip install astroML
$ pip install astroML_addons

(9)healpy
$ sudo port install py27-healpy

(10)
・まず、githubからインストールを試みる
・zip解凍して
$ cd pymc-master/
$ python setup.py config_fc --fcompiler gfortran build
$ python setup.py install

うまくいっているか調べるためにDesktopにpymc_test.pyを作り走らせる:
$ cd ../Desktop/
$ python pymc_test.txt
Running unit tests for pymc.tests
NumPy version 1.7.1
NumPy is installed in /Users/user_name_of_this_mac/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy
Python version 2.7.3 | 64-bit | (default, Aug 8 2013, 05:37:06) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
nose version 1.2.1

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK

全然OKじゃない。笑

・この一連の操作をやったあとに、
$ easy_install pymc
$ python pymc_test.txt

Running unit tests for pymc.tests
NumPy version 1.7.1
NumPy is installed in /Users/user_name_of_this_mac/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy
Python version 2.7.3 | 64-bit | (default, Aug 8 2013, 05:37:06) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
nose version 1.2.1
...............S..S.............S.......................................................................................................0 x
1 (x_pow_2)
dtype: object
.....SS....................[-----------------51% ] 517 of 1000 complete in 0.5 sec
[-----------------91%-------------- ] 912 of 1000 complete in 1.0 sec
[-----------------100%-----------------] 1000 of 1000 complete in 1.1 sec
.[-----------------100%-----------------] 1000 of 1000 complete in 0.4 sec
............
----------------------------------------------------------------------
Ran 175 tests in 27.616s

OK (SKIP=5)

これでようやくうまくいった。