├── .gitignore ├── .travis.yml ├── CREDITS.rst ├── DEVELOPERS.txt ├── LICENSE ├── MANIFEST.in ├── README.rst ├── blas └── BLAS │ ├── dasum.f │ ├── daxpy.f │ ├── dcabs1.f │ ├── dcopy.f │ ├── ddot.f │ ├── dgbmv.f │ ├── dgemm.f │ ├── dgemv.f │ ├── dger.f │ ├── dnrm2.f │ ├── drot.f │ ├── drotg.f │ ├── drotm.f │ ├── drotmg.f │ ├── dsbmv.f │ ├── dscal.f │ ├── dsdot.f │ ├── dspmv.f │ ├── dspr.f │ ├── dspr2.f │ ├── dswap.f │ ├── dsymm.f │ ├── dsymv.f │ ├── dsyr.f │ ├── dsyr2.f │ ├── dsyr2k.f │ ├── dsyrk.f │ ├── dtbmv.f │ ├── dtbsv.f │ ├── dtpmv.f │ ├── dtpsv.f │ ├── dtrmm.f │ ├── dtrmv.f │ ├── dtrsm.f │ ├── dtrsv.f │ ├── dzasum.f │ ├── dznrm2.f │ ├── idamax.f │ ├── lsame.f │ └── xerbla.f ├── builddocs ├── builddpkg ├── buildosx ├── cephes ├── README ├── c2f.c ├── cephes_names.h ├── chbevl.c ├── i0.c ├── mconf.h └── protos.h ├── code_maintenance.py ├── conda ├── bld.bat ├── build.sh ├── meta.yaml └── run_test.py ├── devtools └── build-vm │ └── linux │ ├── Vagrantfile │ ├── build_conda_package_vagrant.sh │ └── setup_centos_vm.sh ├── docs ├── INSTALL.rst ├── Makefile ├── README.rst ├── _images │ ├── DisasterModel2.pdf │ ├── DisasterModel2.png │ ├── PotExample.pdf │ ├── PotExample.png │ ├── autocorr.pdf │ ├── autocorr.png │ ├── deviates.pdf │ ├── deviates.png │ ├── disasterts.pdf │ ├── disasterts.png │ ├── envelope.pdf │ ├── envelope.png │ ├── geweke.pdf │ ├── geweke.png │ ├── gof.pdf │ ├── gof.png │ ├── icon.pdf │ ├── icon.png │ ├── ltrace.pdf │ ├── ltrace.png │ ├── metastable.pdf │ ├── metastable.png │ ├── missing.pdf │ ├── missing.png │ ├── poormixing.pdf │ ├── poormixing.png │ ├── reject.pdf │ ├── reject.png │ ├── spost.pdf │ ├── spost.png │ ├── summary.pdf │ ├── summary.png │ ├── write_csv.pdf │ └── write_csv.png ├── conclusion.rst ├── conf.py ├── database.rst ├── distributions.rst ├── extending.rst ├── index.rst ├── modelbuilding.rst ├── modelchecking.rst ├── modelfitting.rst ├── references.rst ├── theory.rst └── tutorial.rst ├── epydoc.conf ├── lapack └── double │ ├── README │ ├── dbdsdc.f │ ├── dbdsqr.f │ ├── ddisna.f │ ├── dgbbrd.f │ ├── dgbcon.f │ ├── dgbequ.f │ ├── dgbrfs.f │ ├── dgbsv.f │ ├── dgbsvx.f │ ├── dgbtf2.f │ ├── dgbtrf.f │ ├── dgbtrs.f │ ├── dgebak.f │ ├── dgebal.f │ ├── dgebd2.f │ ├── dgebrd.f │ ├── dgecon.f │ ├── dgeequ.f │ ├── dgees.f │ ├── dgeesx.f │ ├── dgeev.f │ ├── dgeevx.f │ ├── dgegs.f │ ├── dgegv.f │ ├── dgehd2.f │ ├── dgehrd.f │ ├── dgelq2.f │ ├── dgelqf.f │ ├── dgels.f │ ├── dgelsd.f │ ├── dgelss.f │ ├── dgelsx.f │ ├── dgelsy.f │ ├── dgeql2.f │ ├── dgeqlf.f │ ├── dgeqp3.f │ ├── dgeqpf.f │ ├── dgeqr2.f │ ├── dgeqrf.f │ ├── dgerfs.f │ ├── dgerq2.f │ ├── dgerqf.f │ ├── dgesc2.f │ ├── dgesdd.f │ ├── dgesv.f │ ├── dgesvd.f │ ├── dgesvx.f │ ├── dgetc2.f │ ├── dgetf2.f │ ├── dgetrf.f │ ├── dgetri.f │ ├── dgetrs.f │ ├── dggbak.f │ ├── dggbal.f │ ├── dgges.f │ ├── dggesx.f │ ├── dggev.f │ ├── dggevx.f │ ├── dggglm.f │ ├── dgghrd.f │ ├── dgglse.f │ ├── dggqrf.f │ ├── dggrqf.f │ ├── dggsvd.f │ ├── dggsvp.f │ ├── dgtcon.f │ ├── dgtrfs.f │ ├── dgtsv.f │ ├── dgtsvx.f │ ├── dgttrf.f │ ├── dgttrs.f │ ├── dgtts2.f │ ├── dhgeqz.f │ ├── dhsein.f │ ├── dhseqr.f │ ├── disnan.f │ ├── dlabad.f │ ├── dlabrd.f │ ├── dlacn2.f │ ├── dlacon.f │ ├── dlacpy.f │ ├── dladiv.f │ ├── dlae2.f │ ├── dlaebz.f │ ├── dlaed0.f │ ├── dlaed1.f │ ├── dlaed2.f │ ├── dlaed3.f │ ├── dlaed4.f │ ├── dlaed5.f │ ├── dlaed6.f │ ├── dlaed7.f │ ├── dlaed8.f │ ├── dlaed9.f │ ├── dlaeda.f │ ├── dlaein.f │ ├── dlaev2.f │ ├── dlaexc.f │ ├── dlag2.f │ ├── dlag2s.f │ ├── dlags2.f │ ├── dlagtf.f │ ├── dlagtm.f │ ├── dlagts.f │ ├── dlagv2.f │ ├── dlahqr.f │ ├── dlahr2.f │ ├── dlahrd.f │ ├── dlaic1.f │ ├── dlaisnan.f │ ├── dlaln2.f │ ├── dlals0.f │ ├── dlalsa.f │ ├── dlalsd.f │ ├── dlamch.f │ ├── dlamrg.f │ ├── dlaneg.f │ ├── dlangb.f │ ├── dlange.f │ ├── dlangt.f │ ├── dlanhs.f │ ├── dlansb.f │ ├── dlansp.f │ ├── dlanst.f │ ├── dlansy.f │ ├── dlantb.f │ ├── dlantp.f │ ├── dlantr.f │ ├── dlanv2.f │ ├── dlapll.f │ ├── dlapmt.f │ ├── dlapy2.f │ ├── dlapy3.f │ ├── dlaqgb.f │ ├── dlaqge.f │ ├── dlaqp2.f │ ├── dlaqps.f │ ├── dlaqr0.f │ ├── dlaqr1.f │ ├── dlaqr2.f │ ├── dlaqr3.f │ ├── dlaqr4.f │ ├── dlaqr5.f │ ├── dlaqsb.f │ ├── dlaqsp.f │ ├── dlaqsy.f │ ├── dlaqtr.f │ ├── dlar1v.f │ ├── dlar2v.f │ ├── dlarf.f │ ├── dlarfb.f │ ├── dlarfg.f │ ├── dlarft.f │ ├── dlarfx.f │ ├── dlargv.f │ ├── dlarnv.f │ ├── dlarra.f │ ├── dlarrb.f │ ├── dlarrc.f │ ├── dlarrd.f │ ├── dlarre.f │ ├── dlarrf.f │ ├── dlarrj.f │ ├── dlarrk.f │ ├── dlarrr.f │ ├── dlarrv.f │ ├── dlartg.f │ ├── dlartv.f │ ├── dlaruv.f │ ├── dlarz.f │ ├── dlarzb.f │ ├── dlarzt.f │ ├── dlas2.f │ ├── dlascl.f │ ├── dlasd0.f │ ├── dlasd1.f │ ├── dlasd2.f │ ├── dlasd3.f │ ├── dlasd4.f │ ├── dlasd5.f │ ├── dlasd6.f │ ├── dlasd7.f │ ├── dlasd8.f │ ├── dlasda.f │ ├── dlasdq.f │ ├── dlasdt.f │ ├── dlaset.f │ ├── dlasq1.f │ ├── dlasq2.f │ ├── dlasq3.f │ ├── dlasq4.f │ ├── dlasq5.f │ ├── dlasq6.f │ ├── dlasr.f │ ├── dlasrt.f │ ├── dlassq.f │ ├── dlasv2.f │ ├── dlaswp.f │ ├── dlasy2.f │ ├── dlasyf.f │ ├── dlatbs.f │ ├── dlatdf.f │ ├── dlatps.f │ ├── dlatrd.f │ ├── dlatrs.f │ ├── dlatrz.f │ ├── dlatzm.f │ ├── dlauu2.f │ ├── dlauum.f │ ├── dlazq3.f │ ├── dlazq4.f │ ├── dopgtr.f │ ├── dopmtr.f │ ├── dorg2l.f │ ├── dorg2r.f │ ├── dorgbr.f │ ├── dorghr.f │ ├── dorgl2.f │ ├── dorglq.f │ ├── dorgql.f │ ├── dorgqr.f │ ├── dorgr2.f │ ├── dorgrq.f │ ├── dorgtr.f │ ├── dorm2l.f │ ├── dorm2r.f │ ├── dormbr.f │ ├── dormhr.f │ ├── dorml2.f │ ├── dormlq.f │ ├── dormql.f │ ├── dormqr.f │ ├── dormr2.f │ ├── dormr3.f │ ├── dormrq.f │ ├── dormrz.f │ ├── dormtr.f │ ├── dpbcon.f │ ├── dpbequ.f │ ├── dpbrfs.f │ ├── dpbstf.f │ ├── dpbsv.f │ ├── dpbsvx.f │ ├── dpbtf2.f │ ├── dpbtrf.f │ ├── dpbtrs.f │ ├── dpocon.f │ ├── dpoequ.f │ ├── dporfs.f │ ├── dposv.f │ ├── dposvx.f │ ├── dpotf2.f │ ├── dpotrf.f │ ├── dpotri.f │ ├── dpotrs.f │ ├── dppcon.f │ ├── dppequ.f │ ├── dpprfs.f │ ├── dppsv.f │ ├── dppsvx.f │ ├── dpptrf.f │ ├── dpptri.f │ ├── dpptrs.f │ ├── dptcon.f │ ├── dpteqr.f │ ├── dptrfs.f │ ├── dptsv.f │ ├── dptsvx.f │ ├── dpttrf.f │ ├── dpttrs.f │ ├── dptts2.f │ ├── drscl.f │ ├── dsbev.f │ ├── dsbevd.f │ ├── dsbevx.f │ ├── dsbgst.f │ ├── dsbgv.f │ ├── dsbgvd.f │ ├── dsbgvx.f │ ├── dsbtrd.f │ ├── dsgesv.f │ ├── dspcon.f │ ├── dspev.f │ ├── dspevd.f │ ├── dspevx.f │ ├── dspgst.f │ ├── dspgv.f │ ├── dspgvd.f │ ├── dspgvx.f │ ├── dsprfs.f │ ├── dspsv.f │ ├── dspsvx.f │ ├── dsptrd.f │ ├── dsptrf.f │ ├── dsptri.f │ ├── dsptrs.f │ ├── dstebz.f │ ├── dstedc.f │ ├── dstegr.f │ ├── dstein.f │ ├── dstemr.f │ ├── dsteqr.f │ ├── dsterf.f │ ├── dstev.f │ ├── dstevd.f │ ├── dstevr.f │ ├── dstevx.f │ ├── dsycon.f │ ├── dsyev.f │ ├── dsyevd.f │ ├── dsyevr.f │ ├── dsyevx.f │ ├── dsygs2.f │ ├── dsygst.f │ ├── dsygv.f │ ├── dsygvd.f │ ├── dsygvx.f │ ├── dsyrfs.f │ ├── dsysv.f │ ├── dsysvx.f │ ├── dsytd2.f │ ├── dsytf2.f │ ├── dsytrd.f │ ├── dsytrf.f │ ├── dsytri.f │ ├── dsytrs.f │ ├── dtbcon.f │ ├── dtbrfs.f │ ├── dtbtrs.f │ ├── dtgevc.f │ ├── dtgex2.f │ ├── dtgexc.f │ ├── dtgsen.f │ ├── dtgsja.f │ ├── dtgsna.f │ ├── dtgsy2.f │ ├── dtgsyl.f │ ├── dtpcon.f │ ├── dtprfs.f │ ├── dtptri.f │ ├── dtptrs.f │ ├── dtrcon.f │ ├── dtrevc.f │ ├── dtrexc.f │ ├── dtrrfs.f │ ├── dtrsen.f │ ├── dtrsna.f │ ├── dtrsyl.f │ ├── dtrti2.f │ ├── dtrtri.f │ ├── dtrtrs.f │ ├── dtzrqf.f │ ├── dtzrzf.f │ ├── dzsum1.f │ ├── ieeeck.f │ ├── ilaenv.f │ ├── ilaver.f │ ├── iparmq.f │ ├── lsame.f │ └── lsamen.f ├── pymc-requirements ├── pymc ├── CircularStochastic.py ├── CommonDeterministics.py ├── Container.py ├── Container_values.c ├── Container_values.pyx ├── InstantiationDecorators.py ├── LazyFunction.c ├── LazyFunction.pyx ├── MCMC.py ├── Matplot.py ├── Model.py ├── Node.py ├── NormalApproximation.py ├── NumpyDeterministics.py ├── PyMCObjects.py ├── ScipyDistributions.py ├── StepMethods.py ├── __init__.py ├── blas_wrap.f ├── calc_utils.py ├── database │ ├── README.rst │ ├── __init__.py │ ├── base.py │ ├── hdf5.py │ ├── hdf5ea.py │ ├── no_trace.py │ ├── pickle.py │ ├── ram.py │ ├── sqlite.py │ └── txt.py ├── datatypes.py ├── decorators.py ├── diagnostics.py ├── distributions.py ├── examples │ ├── __init__.py │ ├── custom_step.py │ ├── disaster_model.py │ ├── disaster_model_gof.py │ ├── disaster_model_linear.py │ ├── disaster_model_missing.py │ ├── disaster_model_null.py │ ├── gelman_bioassay.py │ ├── gp │ │ ├── MCMC.py │ │ ├── PyMCmodel.py │ │ ├── __init__.py │ │ ├── basiscov.py │ │ ├── cov.py │ │ ├── covparams.py │ │ ├── mean.py │ │ ├── mesh_choice.py │ │ ├── more_examples │ │ │ ├── Duffy │ │ │ │ ├── africa.hdf5 │ │ │ │ ├── duffy-jittered.csv │ │ │ │ ├── mcmc.py │ │ │ │ └── model.py │ │ │ ├── Geostats │ │ │ │ ├── getdata.py │ │ │ │ ├── mcmc.py │ │ │ │ ├── model.py │ │ │ │ └── walker_01.dat │ │ │ └── MKMsalmon │ │ │ │ ├── MCMC.py │ │ │ │ ├── chum.csv │ │ │ │ ├── pink.csv │ │ │ │ ├── regression.py │ │ │ │ ├── salmon.py │ │ │ │ ├── salmon_sampler.py │ │ │ │ └── sockeye.csv │ │ ├── observation.py │ │ └── realizations.py │ ├── melanoma.py │ ├── melanoma_data.py │ ├── weibull_fit.py │ ├── weibull_fit_gof.py │ └── zip.py ├── flib.f ├── flib.so.dSYM │ └── Contents │ │ └── Info.plist ├── flib_blas.f ├── gibbsit.f ├── gp │ ├── BasisCovariance.py │ ├── Covariance.py │ ├── Docs │ │ ├── GPUserGuide.tex │ │ ├── algorithm │ │ │ ├── GPAlg.bib │ │ │ ├── GPAlgorithms.tex │ │ │ ├── figs │ │ │ │ ├── ESSBPosterior.pdf │ │ │ │ ├── ESSDPosterior.pdf │ │ │ │ ├── ESSVphiPosterior.pdf │ │ │ │ ├── ESSVpsiPosterior.pdf │ │ │ │ ├── ESSblowfly.dot │ │ │ │ ├── ESSblowfly.pdf │ │ │ │ ├── ESSblowflyfit.pdf │ │ │ │ ├── ESSmuphiPosterior.pdf │ │ │ │ ├── ESSmupsiPosterior.pdf │ │ │ │ ├── MMKchumreg.pdf │ │ │ │ ├── MMKpinkreg.pdf │ │ │ │ ├── MMKsalmon.dot │ │ │ │ ├── MMKsalmon.pdf │ │ │ │ ├── MMKsockeyereg.pdf │ │ │ │ ├── PyMC_cartoon.graffle │ │ │ │ ├── PyMC_cartoon.pdf │ │ │ │ ├── basiscov.pdf │ │ │ │ ├── cond.pdf │ │ │ │ ├── cov.pdf │ │ │ │ ├── d100a1s1.pdf │ │ │ │ ├── d10a1s1.pdf │ │ │ │ ├── d14a1s1.pdf │ │ │ │ ├── d14a1s1close.pdf │ │ │ │ ├── d14a1s4.pdf │ │ │ │ ├── d14a1s4far.pdf │ │ │ │ ├── d14a4s1.pdf │ │ │ │ ├── d20a1s1.pdf │ │ │ │ ├── d2a1s1.pdf │ │ │ │ ├── d4a1s1.pdf │ │ │ │ ├── d5a1s1.pdf │ │ │ │ ├── d8a1s1.pdf │ │ │ │ ├── densemeshpropose.pdf │ │ │ │ ├── elevdraw0.pdf │ │ │ │ ├── elevdraw1.pdf │ │ │ │ ├── elevmean.pdf │ │ │ │ ├── elevvar.pdf │ │ │ │ ├── gibbsSamples.pdf │ │ │ │ ├── lightmeshpropose.pdf │ │ │ │ ├── mean.pdf │ │ │ │ ├── metroSamples.pdf │ │ │ │ ├── nomeshpropose.pdf │ │ │ │ ├── obs.pdf │ │ │ │ ├── obscov.pdf │ │ │ │ ├── observed.dot │ │ │ │ ├── observedModel.pdf │ │ │ │ ├── pinkVpost.pdf │ │ │ │ ├── pinkamppost.pdf │ │ │ │ ├── pinkampscale.pdf │ │ │ │ ├── pinkbeta0post.pdf │ │ │ │ ├── pinkbeta1post.pdf │ │ │ │ ├── pinkdiffdegreepost.pdf │ │ │ │ ├── pinkfpost.pdf │ │ │ │ ├── pinkscalepost.pdf │ │ │ │ ├── prismdraw0.pdf │ │ │ │ ├── prismdraw1.pdf │ │ │ │ ├── prismdraw2.pdf │ │ │ │ ├── prismmean.pdf │ │ │ │ ├── prismvar.pdf │ │ │ │ ├── realizations.pdf │ │ │ │ ├── sampmethod_cartoon.graffle │ │ │ │ ├── sampmethod_cartoon.pdf │ │ │ │ ├── unobserved.dot │ │ │ │ └── unobservedModel.pdf │ │ │ └── underscore.sty │ │ ├── banner.pdf │ │ ├── coverletter.tex │ │ ├── epydocheader.tex │ │ ├── extending.tex │ │ ├── fancyhdr.sty │ │ ├── figs │ │ │ ├── ESSBPosterior.pdf │ │ │ ├── ESSDPosterior.pdf │ │ │ ├── ESSVphiPosterior.pdf │ │ │ ├── ESSVpsiPosterior.pdf │ │ │ ├── ESSblowfly.dot │ │ │ ├── ESSblowfly.pdf │ │ │ ├── ESSblowflyfit.pdf │ │ │ ├── ESSmuphiPosterior.pdf │ │ │ ├── ESSmupsiPosterior.pdf │ │ │ ├── MKMsalmon.dot │ │ │ ├── MKMsalmon.pdf │ │ │ ├── MMKchumreg.pdf │ │ │ ├── MMKpinkreg.pdf │ │ │ ├── MMKsockeyereg.pdf │ │ │ ├── basiscov.pdf │ │ │ ├── cond.pdf │ │ │ ├── cov.pdf │ │ │ ├── d100a1s1.pdf │ │ │ ├── d10a1s1.pdf │ │ │ ├── d14a1s1.pdf │ │ │ ├── d14a1s1close.pdf │ │ │ ├── d14a1s4.pdf │ │ │ ├── d14a1s4far.pdf │ │ │ ├── d14a4s1.pdf │ │ │ ├── d20a1s1.pdf │ │ │ ├── d2a1s1.pdf │ │ │ ├── d4a1s1.pdf │ │ │ ├── d5a1s1.pdf │ │ │ ├── d8a1s1.pdf │ │ │ ├── densemeshpropose.pdf │ │ │ ├── elevdraw0.pdf │ │ │ ├── elevdraw1.pdf │ │ │ ├── elevmean.pdf │ │ │ ├── elevvar.pdf │ │ │ ├── gibbsSamples.pdf │ │ │ ├── lightmeshpropose.pdf │ │ │ ├── mean.pdf │ │ │ ├── metroSamples.pdf │ │ │ ├── nomeshpropose.pdf │ │ │ ├── obs.pdf │ │ │ ├── obscov.pdf │ │ │ ├── observed.dot │ │ │ ├── observedModel.pdf │ │ │ ├── pinkVpost.pdf │ │ │ ├── pinkamppost.pdf │ │ │ ├── pinkampscale.pdf │ │ │ ├── pinkbeta0post.pdf │ │ │ ├── pinkbeta1post.pdf │ │ │ ├── pinkdiffdegreepost.pdf │ │ │ ├── pinkfpost.pdf │ │ │ ├── pinkscalepost.pdf │ │ │ ├── prismdraw0.pdf │ │ │ ├── prismdraw1.pdf │ │ │ ├── prismdraw2.pdf │ │ │ ├── prismmean.pdf │ │ │ ├── prismvar.pdf │ │ │ ├── realizations.pdf │ │ │ ├── unobserved.dot │ │ │ ├── unobservedModel.dot │ │ │ └── unobservedModel.pdf │ │ ├── fncychap.sty │ │ ├── gp.bib │ │ ├── jss-gp.aux │ │ ├── jss-gp.bib │ │ ├── jss-gp.fdb_latexmk │ │ ├── jss-gp.fls │ │ ├── jss-gp.log │ │ ├── jss-gp.tex │ │ ├── logo_purple.pdf │ │ ├── ltxmarkup.sty │ │ ├── manual.cls │ │ ├── numerics.tex │ │ ├── pymcchap.sty │ │ ├── pypaper.sty │ │ ├── python.ist │ │ ├── python.sty │ │ ├── tutorial1.tex │ │ ├── tutorial2.tex │ │ └── underscore.sty │ ├── FullRankCovariance.py │ ├── GPutils.py │ ├── Mean.py │ ├── NearlyFullRankCovariance.py │ ├── Realization.py │ ├── __init__.py │ ├── cov_funs │ │ ├── __init__.py │ │ ├── bases.py │ │ ├── brownian.py │ │ ├── cov_utils.py │ │ ├── distances.f │ │ ├── distances.so.dSYM │ │ │ └── Contents │ │ │ │ └── Info.plist │ │ ├── isotropic_cov_funs.f │ │ ├── isotropic_cov_funs.so.dSYM │ │ │ └── Contents │ │ │ │ └── Info.plist │ │ ├── nsmatern.py │ │ └── wrapped_distances.py │ ├── epydoc.conf │ ├── gp_submodel.py │ ├── gpplots.py │ ├── incomplete_chol.f │ ├── incomplete_chol.so.dSYM │ │ └── Contents │ │ │ └── Info.plist │ ├── linalg_utils.f │ ├── linalg_utils.so.dSYM │ │ └── Contents │ │ │ └── Info.plist │ └── step_methods.py ├── graph.py ├── histogram.f ├── math.f ├── progressbar.py ├── six.py ├── tests │ ├── __init__.py │ ├── objectmodel.py │ ├── test_AM.py │ ├── test_GP_MCMC.py │ ├── test_MCMCSampler.py │ ├── test_adaptive.py │ ├── test_basiscov.py │ ├── test_binary_step.py │ ├── test_container.py │ ├── test_convergence.py │ ├── test_cov.py │ ├── test_database.py │ ├── test_distributions.py │ ├── test_gradients.py │ ├── test_graph.py │ ├── test_instantiation.py │ ├── test_interactive.py │ ├── test_mean.py │ ├── test_missing.py │ ├── test_norm_approx.py │ ├── test_observation.py │ ├── test_realization.py │ ├── test_slice.py │ ├── test_special_methods.py │ └── test_utils.py ├── threadpool.py └── utils.py ├── setup.py ├── setupegg.py └── stdeb_all.cfg /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.so 3 | build/* 4 | dist/* 5 | pymc.egg-info/ 6 | UNKNOWN.egg-info/ 7 | docs/_build 8 | MANIFEST 9 | develop 10 | testresults 11 | *.tmproj 12 | *.py.bak 13 | .DS_Store 14 | *cpython* -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | sudo: false 3 | 4 | 5 | matrix: 6 | include: 7 | - python: 2.7 8 | - python: 3.4 9 | addons: 10 | apt: 11 | packages: 12 | - libatlas-dev 13 | - libatlas-base-dev 14 | - liblapack-dev 15 | - gfortran 16 | before_install: 17 | - sh -e /etc/init.d/xvfb start 18 | - export DISPLAY=":99.0" 19 | - travis_retry pip install --install-option="--no-cython-compile" Cython==0.22 20 | - travis_retry pip install numpy scipy nose matplotlib pandas 21 | install: 22 | - python setup.py build_ext --inplace 23 | script: 24 | - nosetests -s pymc/tests/ 25 | -------------------------------------------------------------------------------- /CREDITS.rst: -------------------------------------------------------------------------------- 1 | ************ 2 | PyMC Credits 3 | ************ 4 | 5 | Development team 6 | ================ 7 | 8 | * Christopher Fonnesbeck 9 | * David Huard 10 | * Anand Patil 11 | * John Salvatier 12 | 13 | Contributors 14 | ============ 15 | 16 | * Andrew Straw : the Von Mises distribution and code to strip trailing whitespace. 17 | * Max Nickel : A bugfix in the Raftery-Lewis convergence diagnostic 18 | * Joonas Paalasmaa : Fixed an installation bug 19 | * Nicholas Matsakis : Changed typographer's quotes to straight quotes in documentation 20 | * Nick Ward : Fixed breaking behaviour for Python 3 21 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include setup.py *.rst *.cfg *.conf LICENSE docs/UserGuide.pdf 2 | recursive-include pymc *.pyx *.py *.rst *.txt 3 | -------------------------------------------------------------------------------- /blas/BLAS/dasum.f: -------------------------------------------------------------------------------- 1 | DOUBLE PRECISION FUNCTION DASUM(N,DX,INCX) 2 | * .. Scalar Arguments .. 3 | INTEGER INCX,N 4 | * .. 5 | * .. Array Arguments .. 6 | DOUBLE PRECISION DX(*) 7 | * .. 8 | * 9 | * Purpose 10 | * ======= 11 | * 12 | * takes the sum of the absolute values. 13 | * jack dongarra, linpack, 3/11/78. 14 | * modified 3/93 to return if incx .le. 0. 15 | * modified 12/3/93, array(1) declarations changed to array(*) 16 | * 17 | * 18 | * .. Local Scalars .. 19 | DOUBLE PRECISION DTEMP 20 | INTEGER I,M,MP1,NINCX 21 | * .. 22 | * .. Intrinsic Functions .. 23 | INTRINSIC DABS,MOD 24 | * .. 25 | DASUM = 0.0d0 26 | DTEMP = 0.0d0 27 | IF (N.LE.0 .OR. INCX.LE.0) RETURN 28 | IF (INCX.EQ.1) GO TO 20 29 | * 30 | * code for increment not equal to 1 31 | * 32 | NINCX = N*INCX 33 | DO 10 I = 1,NINCX,INCX 34 | DTEMP = DTEMP + DABS(DX(I)) 35 | 10 CONTINUE 36 | DASUM = DTEMP 37 | RETURN 38 | * 39 | * code for increment equal to 1 40 | * 41 | * 42 | * clean-up loop 43 | * 44 | 20 M = MOD(N,6) 45 | IF (M.EQ.0) GO TO 40 46 | DO 30 I = 1,M 47 | DTEMP = DTEMP + DABS(DX(I)) 48 | 30 CONTINUE 49 | IF (N.LT.6) GO TO 60 50 | 40 MP1 = M + 1 51 | DO 50 I = MP1,N,6 52 | DTEMP = DTEMP + DABS(DX(I)) + DABS(DX(I+1)) + DABS(DX(I+2)) + 53 | + DABS(DX(I+3)) + DABS(DX(I+4)) + DABS(DX(I+5)) 54 | 50 CONTINUE 55 | 60 DASUM = DTEMP 56 | RETURN 57 | END 58 | -------------------------------------------------------------------------------- /blas/BLAS/daxpy.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DAXPY(N,DA,DX,INCX,DY,INCY) 2 | * .. Scalar Arguments .. 3 | DOUBLE PRECISION DA 4 | INTEGER INCX,INCY,N 5 | * .. 6 | * .. Array Arguments .. 7 | DOUBLE PRECISION DX(*),DY(*) 8 | * .. 9 | * 10 | * Purpose 11 | * ======= 12 | * 13 | * constant times a vector plus a vector. 14 | * uses unrolled loops for increments equal to one. 15 | * jack dongarra, linpack, 3/11/78. 16 | * modified 12/3/93, array(1) declarations changed to array(*) 17 | * 18 | * 19 | * .. Local Scalars .. 20 | INTEGER I,IX,IY,M,MP1 21 | * .. 22 | * .. Intrinsic Functions .. 23 | INTRINSIC MOD 24 | * .. 25 | IF (N.LE.0) RETURN 26 | IF (DA.EQ.0.0d0) RETURN 27 | IF (INCX.EQ.1 .AND. INCY.EQ.1) GO TO 20 28 | * 29 | * code for unequal increments or equal increments 30 | * not equal to 1 31 | * 32 | IX = 1 33 | IY = 1 34 | IF (INCX.LT.0) IX = (-N+1)*INCX + 1 35 | IF (INCY.LT.0) IY = (-N+1)*INCY + 1 36 | DO 10 I = 1,N 37 | DY(IY) = DY(IY) + DA*DX(IX) 38 | IX = IX + INCX 39 | IY = IY + INCY 40 | 10 CONTINUE 41 | RETURN 42 | * 43 | * code for both increments equal to 1 44 | * 45 | * 46 | * clean-up loop 47 | * 48 | 20 M = MOD(N,4) 49 | IF (M.EQ.0) GO TO 40 50 | DO 30 I = 1,M 51 | DY(I) = DY(I) + DA*DX(I) 52 | 30 CONTINUE 53 | IF (N.LT.4) RETURN 54 | 40 MP1 = M + 1 55 | DO 50 I = MP1,N,4 56 | DY(I) = DY(I) + DA*DX(I) 57 | DY(I+1) = DY(I+1) + DA*DX(I+1) 58 | DY(I+2) = DY(I+2) + DA*DX(I+2) 59 | DY(I+3) = DY(I+3) + DA*DX(I+3) 60 | 50 CONTINUE 61 | RETURN 62 | END 63 | -------------------------------------------------------------------------------- /blas/BLAS/dcabs1.f: -------------------------------------------------------------------------------- 1 | DOUBLE PRECISION FUNCTION DCABS1(Z) 2 | * .. Scalar Arguments .. 3 | DOUBLE COMPLEX Z 4 | * .. 5 | * .. 6 | * Purpose 7 | * ======= 8 | * 9 | * DCABS1 computes absolute value of a double complex number 10 | * 11 | * .. Intrinsic Functions .. 12 | INTRINSIC ABS,DBLE,DIMAG 13 | * 14 | DCABS1 = ABS(DBLE(Z)) + ABS(DIMAG(Z)) 15 | RETURN 16 | END 17 | -------------------------------------------------------------------------------- /blas/BLAS/dcopy.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DCOPY(N,DX,INCX,DY,INCY) 2 | * .. Scalar Arguments .. 3 | INTEGER INCX,INCY,N 4 | * .. 5 | * .. Array Arguments .. 6 | DOUBLE PRECISION DX(*),DY(*) 7 | * .. 8 | * 9 | * Purpose 10 | * ======= 11 | * 12 | * copies a vector, x, to a vector, y. 13 | * uses unrolled loops for increments equal to one. 14 | * jack dongarra, linpack, 3/11/78. 15 | * modified 12/3/93, array(1) declarations changed to array(*) 16 | * 17 | * 18 | * .. Local Scalars .. 19 | INTEGER I,IX,IY,M,MP1 20 | * .. 21 | * .. Intrinsic Functions .. 22 | INTRINSIC MOD 23 | * .. 24 | IF (N.LE.0) RETURN 25 | IF (INCX.EQ.1 .AND. INCY.EQ.1) GO TO 20 26 | * 27 | * code for unequal increments or equal increments 28 | * not equal to 1 29 | * 30 | IX = 1 31 | IY = 1 32 | IF (INCX.LT.0) IX = (-N+1)*INCX + 1 33 | IF (INCY.LT.0) IY = (-N+1)*INCY + 1 34 | DO 10 I = 1,N 35 | DY(IY) = DX(IX) 36 | IX = IX + INCX 37 | IY = IY + INCY 38 | 10 CONTINUE 39 | RETURN 40 | * 41 | * code for both increments equal to 1 42 | * 43 | * 44 | * clean-up loop 45 | * 46 | 20 M = MOD(N,7) 47 | IF (M.EQ.0) GO TO 40 48 | DO 30 I = 1,M 49 | DY(I) = DX(I) 50 | 30 CONTINUE 51 | IF (N.LT.7) RETURN 52 | 40 MP1 = M + 1 53 | DO 50 I = MP1,N,7 54 | DY(I) = DX(I) 55 | DY(I+1) = DX(I+1) 56 | DY(I+2) = DX(I+2) 57 | DY(I+3) = DX(I+3) 58 | DY(I+4) = DX(I+4) 59 | DY(I+5) = DX(I+5) 60 | DY(I+6) = DX(I+6) 61 | 50 CONTINUE 62 | RETURN 63 | END 64 | -------------------------------------------------------------------------------- /blas/BLAS/ddot.f: -------------------------------------------------------------------------------- 1 | DOUBLE PRECISION FUNCTION DDOT(N,DX,INCX,DY,INCY) 2 | * .. Scalar Arguments .. 3 | INTEGER INCX,INCY,N 4 | * .. 5 | * .. Array Arguments .. 6 | DOUBLE PRECISION DX(*),DY(*) 7 | * .. 8 | * 9 | * Purpose 10 | * ======= 11 | * 12 | * forms the dot product of two vectors. 13 | * uses unrolled loops for increments equal to one. 14 | * jack dongarra, linpack, 3/11/78. 15 | * modified 12/3/93, array(1) declarations changed to array(*) 16 | * 17 | * 18 | * .. Local Scalars .. 19 | DOUBLE PRECISION DTEMP 20 | INTEGER I,IX,IY,M,MP1 21 | * .. 22 | * .. Intrinsic Functions .. 23 | INTRINSIC MOD 24 | * .. 25 | DDOT = 0.0d0 26 | DTEMP = 0.0d0 27 | IF (N.LE.0) RETURN 28 | IF (INCX.EQ.1 .AND. INCY.EQ.1) GO TO 20 29 | * 30 | * code for unequal increments or equal increments 31 | * not equal to 1 32 | * 33 | IX = 1 34 | IY = 1 35 | IF (INCX.LT.0) IX = (-N+1)*INCX + 1 36 | IF (INCY.LT.0) IY = (-N+1)*INCY + 1 37 | DO 10 I = 1,N 38 | DTEMP = DTEMP + DX(IX)*DY(IY) 39 | IX = IX + INCX 40 | IY = IY + INCY 41 | 10 CONTINUE 42 | DDOT = DTEMP 43 | RETURN 44 | * 45 | * code for both increments equal to 1 46 | * 47 | * 48 | * clean-up loop 49 | * 50 | 20 M = MOD(N,5) 51 | IF (M.EQ.0) GO TO 40 52 | DO 30 I = 1,M 53 | DTEMP = DTEMP + DX(I)*DY(I) 54 | 30 CONTINUE 55 | IF (N.LT.5) GO TO 60 56 | 40 MP1 = M + 1 57 | DO 50 I = MP1,N,5 58 | DTEMP = DTEMP + DX(I)*DY(I) + DX(I+1)*DY(I+1) + 59 | + DX(I+2)*DY(I+2) + DX(I+3)*DY(I+3) + DX(I+4)*DY(I+4) 60 | 50 CONTINUE 61 | 60 DDOT = DTEMP 62 | RETURN 63 | END 64 | -------------------------------------------------------------------------------- /blas/BLAS/dnrm2.f: -------------------------------------------------------------------------------- 1 | DOUBLE PRECISION FUNCTION DNRM2(N,X,INCX) 2 | * .. Scalar Arguments .. 3 | INTEGER INCX,N 4 | * .. 5 | * .. Array Arguments .. 6 | DOUBLE PRECISION X(*) 7 | * .. 8 | * 9 | * Purpose 10 | * ======= 11 | * 12 | * DNRM2 returns the euclidean norm of a vector via the function 13 | * name, so that 14 | * 15 | * DNRM2 := sqrt( x'*x ) 16 | * 17 | * 18 | * -- This version written on 25-October-1982. 19 | * Modified on 14-October-1993 to inline the call to DLASSQ. 20 | * Sven Hammarling, Nag Ltd. 21 | * 22 | * 23 | * .. Parameters .. 24 | DOUBLE PRECISION ONE,ZERO 25 | PARAMETER (ONE=1.0D+0,ZERO=0.0D+0) 26 | * .. 27 | * .. Local Scalars .. 28 | DOUBLE PRECISION ABSXI,NORM,SCALE,SSQ 29 | INTEGER IX 30 | * .. 31 | * .. Intrinsic Functions .. 32 | INTRINSIC ABS,SQRT 33 | * .. 34 | IF (N.LT.1 .OR. INCX.LT.1) THEN 35 | NORM = ZERO 36 | ELSE IF (N.EQ.1) THEN 37 | NORM = ABS(X(1)) 38 | ELSE 39 | SCALE = ZERO 40 | SSQ = ONE 41 | * The following loop is equivalent to this call to the LAPACK 42 | * auxiliary routine: 43 | * CALL DLASSQ( N, X, INCX, SCALE, SSQ ) 44 | * 45 | DO 10 IX = 1,1 + (N-1)*INCX,INCX 46 | IF (X(IX).NE.ZERO) THEN 47 | ABSXI = ABS(X(IX)) 48 | IF (SCALE.LT.ABSXI) THEN 49 | SSQ = ONE + SSQ* (SCALE/ABSXI)**2 50 | SCALE = ABSXI 51 | ELSE 52 | SSQ = SSQ + (ABSXI/SCALE)**2 53 | END IF 54 | END IF 55 | 10 CONTINUE 56 | NORM = SCALE*SQRT(SSQ) 57 | END IF 58 | * 59 | DNRM2 = NORM 60 | RETURN 61 | * 62 | * End of DNRM2. 63 | * 64 | END 65 | -------------------------------------------------------------------------------- /blas/BLAS/drot.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DROT(N,DX,INCX,DY,INCY,C,S) 2 | * .. Scalar Arguments .. 3 | DOUBLE PRECISION C,S 4 | INTEGER INCX,INCY,N 5 | * .. 6 | * .. Array Arguments .. 7 | DOUBLE PRECISION DX(*),DY(*) 8 | * .. 9 | * 10 | * Purpose 11 | * ======= 12 | * 13 | * applies a plane rotation. 14 | * jack dongarra, linpack, 3/11/78. 15 | * modified 12/3/93, array(1) declarations changed to array(*) 16 | * 17 | * 18 | * .. Local Scalars .. 19 | DOUBLE PRECISION DTEMP 20 | INTEGER I,IX,IY 21 | * .. 22 | IF (N.LE.0) RETURN 23 | IF (INCX.EQ.1 .AND. INCY.EQ.1) GO TO 20 24 | * 25 | * code for unequal increments or equal increments not equal 26 | * to 1 27 | * 28 | IX = 1 29 | IY = 1 30 | IF (INCX.LT.0) IX = (-N+1)*INCX + 1 31 | IF (INCY.LT.0) IY = (-N+1)*INCY + 1 32 | DO 10 I = 1,N 33 | DTEMP = C*DX(IX) + S*DY(IY) 34 | DY(IY) = C*DY(IY) - S*DX(IX) 35 | DX(IX) = DTEMP 36 | IX = IX + INCX 37 | IY = IY + INCY 38 | 10 CONTINUE 39 | RETURN 40 | * 41 | * code for both increments equal to 1 42 | * 43 | 20 DO 30 I = 1,N 44 | DTEMP = C*DX(I) + S*DY(I) 45 | DY(I) = C*DY(I) - S*DX(I) 46 | DX(I) = DTEMP 47 | 30 CONTINUE 48 | RETURN 49 | END 50 | -------------------------------------------------------------------------------- /blas/BLAS/drotg.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DROTG(DA,DB,C,S) 2 | * .. Scalar Arguments .. 3 | DOUBLE PRECISION C,DA,DB,S 4 | * .. 5 | * 6 | * Purpose 7 | * ======= 8 | * 9 | * construct givens plane rotation. 10 | * jack dongarra, linpack, 3/11/78. 11 | * 12 | * 13 | * .. Local Scalars .. 14 | DOUBLE PRECISION R,ROE,SCALE,Z 15 | * .. 16 | * .. Intrinsic Functions .. 17 | INTRINSIC DABS,DSIGN,DSQRT 18 | * .. 19 | ROE = DB 20 | IF (DABS(DA).GT.DABS(DB)) ROE = DA 21 | SCALE = DABS(DA) + DABS(DB) 22 | IF (SCALE.NE.0.0d0) GO TO 10 23 | C = 1.0d0 24 | S = 0.0d0 25 | R = 0.0d0 26 | Z = 0.0d0 27 | GO TO 20 28 | 10 R = SCALE*DSQRT((DA/SCALE)**2+ (DB/SCALE)**2) 29 | R = DSIGN(1.0d0,ROE)*R 30 | C = DA/R 31 | S = DB/R 32 | Z = 1.0d0 33 | IF (DABS(DA).GT.DABS(DB)) Z = S 34 | IF (DABS(DB).GE.DABS(DA) .AND. C.NE.0.0d0) Z = 1.0d0/C 35 | 20 DA = R 36 | DB = Z 37 | RETURN 38 | END 39 | -------------------------------------------------------------------------------- /blas/BLAS/dscal.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DSCAL(N,DA,DX,INCX) 2 | * .. Scalar Arguments .. 3 | DOUBLE PRECISION DA 4 | INTEGER INCX,N 5 | * .. 6 | * .. Array Arguments .. 7 | DOUBLE PRECISION DX(*) 8 | * .. 9 | * 10 | * Purpose 11 | * ======= 12 | ** 13 | * scales a vector by a constant. 14 | * uses unrolled loops for increment equal to one. 15 | * jack dongarra, linpack, 3/11/78. 16 | * modified 3/93 to return if incx .le. 0. 17 | * modified 12/3/93, array(1) declarations changed to array(*) 18 | * 19 | * 20 | * .. Local Scalars .. 21 | INTEGER I,M,MP1,NINCX 22 | * .. 23 | * .. Intrinsic Functions .. 24 | INTRINSIC MOD 25 | * .. 26 | IF (N.LE.0 .OR. INCX.LE.0) RETURN 27 | IF (INCX.EQ.1) GO TO 20 28 | * 29 | * code for increment not equal to 1 30 | * 31 | NINCX = N*INCX 32 | DO 10 I = 1,NINCX,INCX 33 | DX(I) = DA*DX(I) 34 | 10 CONTINUE 35 | RETURN 36 | * 37 | * code for increment equal to 1 38 | * 39 | * 40 | * clean-up loop 41 | * 42 | 20 M = MOD(N,5) 43 | IF (M.EQ.0) GO TO 40 44 | DO 30 I = 1,M 45 | DX(I) = DA*DX(I) 46 | 30 CONTINUE 47 | IF (N.LT.5) RETURN 48 | 40 MP1 = M + 1 49 | DO 50 I = MP1,N,5 50 | DX(I) = DA*DX(I) 51 | DX(I+1) = DA*DX(I+1) 52 | DX(I+2) = DA*DX(I+2) 53 | DX(I+3) = DA*DX(I+3) 54 | DX(I+4) = DA*DX(I+4) 55 | 50 CONTINUE 56 | RETURN 57 | END 58 | -------------------------------------------------------------------------------- /blas/BLAS/dswap.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DSWAP(N,DX,INCX,DY,INCY) 2 | * .. Scalar Arguments .. 3 | INTEGER INCX,INCY,N 4 | * .. 5 | * .. Array Arguments .. 6 | DOUBLE PRECISION DX(*),DY(*) 7 | * .. 8 | * 9 | * Purpose 10 | * ======= 11 | * 12 | * interchanges two vectors. 13 | * uses unrolled loops for increments equal one. 14 | * jack dongarra, linpack, 3/11/78. 15 | * modified 12/3/93, array(1) declarations changed to array(*) 16 | * 17 | * 18 | * .. Local Scalars .. 19 | DOUBLE PRECISION DTEMP 20 | INTEGER I,IX,IY,M,MP1 21 | * .. 22 | * .. Intrinsic Functions .. 23 | INTRINSIC MOD 24 | * .. 25 | IF (N.LE.0) RETURN 26 | IF (INCX.EQ.1 .AND. INCY.EQ.1) GO TO 20 27 | * 28 | * code for unequal increments or equal increments not equal 29 | * to 1 30 | * 31 | IX = 1 32 | IY = 1 33 | IF (INCX.LT.0) IX = (-N+1)*INCX + 1 34 | IF (INCY.LT.0) IY = (-N+1)*INCY + 1 35 | DO 10 I = 1,N 36 | DTEMP = DX(IX) 37 | DX(IX) = DY(IY) 38 | DY(IY) = DTEMP 39 | IX = IX + INCX 40 | IY = IY + INCY 41 | 10 CONTINUE 42 | RETURN 43 | * 44 | * code for both increments equal to 1 45 | * 46 | * 47 | * clean-up loop 48 | * 49 | 20 M = MOD(N,3) 50 | IF (M.EQ.0) GO TO 40 51 | DO 30 I = 1,M 52 | DTEMP = DX(I) 53 | DX(I) = DY(I) 54 | DY(I) = DTEMP 55 | 30 CONTINUE 56 | IF (N.LT.3) RETURN 57 | 40 MP1 = M + 1 58 | DO 50 I = MP1,N,3 59 | DTEMP = DX(I) 60 | DX(I) = DY(I) 61 | DY(I) = DTEMP 62 | DTEMP = DX(I+1) 63 | DX(I+1) = DY(I+1) 64 | DY(I+1) = DTEMP 65 | DTEMP = DX(I+2) 66 | DX(I+2) = DY(I+2) 67 | DY(I+2) = DTEMP 68 | 50 CONTINUE 69 | RETURN 70 | END 71 | -------------------------------------------------------------------------------- /blas/BLAS/dzasum.f: -------------------------------------------------------------------------------- 1 | DOUBLE PRECISION FUNCTION DZASUM(N,ZX,INCX) 2 | * .. Scalar Arguments .. 3 | INTEGER INCX,N 4 | * .. 5 | * .. Array Arguments .. 6 | DOUBLE COMPLEX ZX(*) 7 | * .. 8 | * 9 | * Purpose 10 | * ======= 11 | * 12 | * takes the sum of the absolute values. 13 | * jack dongarra, 3/11/78. 14 | * modified 3/93 to return if incx .le. 0. 15 | * modified 12/3/93, array(1) declarations changed to array(*) 16 | * 17 | * 18 | * .. Local Scalars .. 19 | DOUBLE PRECISION STEMP 20 | INTEGER I,IX 21 | * .. 22 | * .. External Functions .. 23 | DOUBLE PRECISION DCABS1 24 | EXTERNAL DCABS1 25 | * .. 26 | DZASUM = 0.0d0 27 | STEMP = 0.0d0 28 | IF (N.LE.0 .OR. INCX.LE.0) RETURN 29 | IF (INCX.EQ.1) GO TO 20 30 | * 31 | * code for increment not equal to 1 32 | * 33 | IX = 1 34 | DO 10 I = 1,N 35 | STEMP = STEMP + DCABS1(ZX(IX)) 36 | IX = IX + INCX 37 | 10 CONTINUE 38 | DZASUM = STEMP 39 | RETURN 40 | * 41 | * code for increment equal to 1 42 | * 43 | 20 DO 30 I = 1,N 44 | STEMP = STEMP + DCABS1(ZX(I)) 45 | 30 CONTINUE 46 | DZASUM = STEMP 47 | RETURN 48 | END 49 | -------------------------------------------------------------------------------- /blas/BLAS/dznrm2.f: -------------------------------------------------------------------------------- 1 | DOUBLE PRECISION FUNCTION DZNRM2(N,X,INCX) 2 | * .. Scalar Arguments .. 3 | INTEGER INCX,N 4 | * .. 5 | * .. Array Arguments .. 6 | DOUBLE COMPLEX X(*) 7 | * .. 8 | * 9 | * Purpose 10 | * ======= 11 | * 12 | * DZNRM2 returns the euclidean norm of a vector via the function 13 | * name, so that 14 | * 15 | * DZNRM2 := sqrt( conjg( x' )*x ) 16 | * 17 | * 18 | * -- This version written on 25-October-1982. 19 | * Modified on 14-October-1993 to inline the call to ZLASSQ. 20 | * Sven Hammarling, Nag Ltd. 21 | * 22 | * 23 | * .. Parameters .. 24 | DOUBLE PRECISION ONE,ZERO 25 | PARAMETER (ONE=1.0D+0,ZERO=0.0D+0) 26 | * .. 27 | * .. Local Scalars .. 28 | DOUBLE PRECISION NORM,SCALE,SSQ,TEMP 29 | INTEGER IX 30 | * .. 31 | * .. Intrinsic Functions .. 32 | INTRINSIC ABS,DBLE,DIMAG,SQRT 33 | * .. 34 | IF (N.LT.1 .OR. INCX.LT.1) THEN 35 | NORM = ZERO 36 | ELSE 37 | SCALE = ZERO 38 | SSQ = ONE 39 | * The following loop is equivalent to this call to the LAPACK 40 | * auxiliary routine: 41 | * CALL ZLASSQ( N, X, INCX, SCALE, SSQ ) 42 | * 43 | DO 10 IX = 1,1 + (N-1)*INCX,INCX 44 | IF (DBLE(X(IX)).NE.ZERO) THEN 45 | TEMP = ABS(DBLE(X(IX))) 46 | IF (SCALE.LT.TEMP) THEN 47 | SSQ = ONE + SSQ* (SCALE/TEMP)**2 48 | SCALE = TEMP 49 | ELSE 50 | SSQ = SSQ + (TEMP/SCALE)**2 51 | END IF 52 | END IF 53 | IF (DIMAG(X(IX)).NE.ZERO) THEN 54 | TEMP = ABS(DIMAG(X(IX))) 55 | IF (SCALE.LT.TEMP) THEN 56 | SSQ = ONE + SSQ* (SCALE/TEMP)**2 57 | SCALE = TEMP 58 | ELSE 59 | SSQ = SSQ + (TEMP/SCALE)**2 60 | END IF 61 | END IF 62 | 10 CONTINUE 63 | NORM = SCALE*SQRT(SSQ) 64 | END IF 65 | * 66 | DZNRM2 = NORM 67 | RETURN 68 | * 69 | * End of DZNRM2. 70 | * 71 | END 72 | -------------------------------------------------------------------------------- /blas/BLAS/idamax.f: -------------------------------------------------------------------------------- 1 | INTEGER FUNCTION IDAMAX(N,DX,INCX) 2 | * .. Scalar Arguments .. 3 | INTEGER INCX,N 4 | * .. 5 | * .. Array Arguments .. 6 | DOUBLE PRECISION DX(*) 7 | * .. 8 | * 9 | * Purpose 10 | * ======= 11 | * 12 | * finds the index of element having max. absolute value. 13 | * jack dongarra, linpack, 3/11/78. 14 | * modified 3/93 to return if incx .le. 0. 15 | * modified 12/3/93, array(1) declarations changed to array(*) 16 | * 17 | * 18 | * .. Local Scalars .. 19 | DOUBLE PRECISION DMAX 20 | INTEGER I,IX 21 | * .. 22 | * .. Intrinsic Functions .. 23 | INTRINSIC DABS 24 | * .. 25 | IDAMAX = 0 26 | IF (N.LT.1 .OR. INCX.LE.0) RETURN 27 | IDAMAX = 1 28 | IF (N.EQ.1) RETURN 29 | IF (INCX.EQ.1) GO TO 20 30 | * 31 | * code for increment not equal to 1 32 | * 33 | IX = 1 34 | DMAX = DABS(DX(1)) 35 | IX = IX + INCX 36 | DO 10 I = 2,N 37 | IF (DABS(DX(IX)).LE.DMAX) GO TO 5 38 | IDAMAX = I 39 | DMAX = DABS(DX(IX)) 40 | 5 IX = IX + INCX 41 | 10 CONTINUE 42 | RETURN 43 | * 44 | * code for increment equal to 1 45 | * 46 | 20 DMAX = DABS(DX(1)) 47 | DO 30 I = 2,N 48 | IF (DABS(DX(I)).LE.DMAX) GO TO 30 49 | IDAMAX = I 50 | DMAX = DABS(DX(I)) 51 | 30 CONTINUE 52 | RETURN 53 | END 54 | -------------------------------------------------------------------------------- /blas/BLAS/lsame.f: -------------------------------------------------------------------------------- 1 | LOGICAL FUNCTION LSAME(CA,CB) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | CHARACTER CA,CB 9 | * .. 10 | * 11 | * Purpose 12 | * ======= 13 | * 14 | * LSAME returns .TRUE. if CA is the same letter as CB regardless of 15 | * case. 16 | * 17 | * Arguments 18 | * ========= 19 | * 20 | * CA (input) CHARACTER*1 21 | * 22 | * CB (input) CHARACTER*1 23 | * CA and CB specify the single characters to be compared. 24 | * 25 | * ===================================================================== 26 | * 27 | * .. Intrinsic Functions .. 28 | INTRINSIC ICHAR 29 | * .. 30 | * .. Local Scalars .. 31 | INTEGER INTA,INTB,ZCODE 32 | * .. 33 | * 34 | * Test if the characters are equal 35 | * 36 | LSAME = CA .EQ. CB 37 | IF (LSAME) RETURN 38 | * 39 | * Now test for equivalence if both characters are alphabetic. 40 | * 41 | ZCODE = ICHAR('Z') 42 | * 43 | * Use 'Z' rather than 'A' so that ASCII can be detected on Prime 44 | * machines, on which ICHAR returns a value with bit 8 set. 45 | * ICHAR('A') on Prime machines returns 193 which is the same as 46 | * ICHAR('A') on an EBCDIC machine. 47 | * 48 | INTA = ICHAR(CA) 49 | INTB = ICHAR(CB) 50 | * 51 | IF (ZCODE.EQ.90 .OR. ZCODE.EQ.122) THEN 52 | * 53 | * ASCII is assumed - ZCODE is the ASCII code of either lower or 54 | * upper case 'Z'. 55 | * 56 | IF (INTA.GE.97 .AND. INTA.LE.122) INTA = INTA - 32 57 | IF (INTB.GE.97 .AND. INTB.LE.122) INTB = INTB - 32 58 | * 59 | ELSE IF (ZCODE.EQ.233 .OR. ZCODE.EQ.169) THEN 60 | * 61 | * EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or 62 | * upper case 'Z'. 63 | * 64 | IF (INTA.GE.129 .AND. INTA.LE.137 .OR. 65 | + INTA.GE.145 .AND. INTA.LE.153 .OR. 66 | + INTA.GE.162 .AND. INTA.LE.169) INTA = INTA + 64 67 | IF (INTB.GE.129 .AND. INTB.LE.137 .OR. 68 | + INTB.GE.145 .AND. INTB.LE.153 .OR. 69 | + INTB.GE.162 .AND. INTB.LE.169) INTB = INTB + 64 70 | * 71 | ELSE IF (ZCODE.EQ.218 .OR. ZCODE.EQ.250) THEN 72 | * 73 | * ASCII is assumed, on Prime machines - ZCODE is the ASCII code 74 | * plus 128 of either lower or upper case 'Z'. 75 | * 76 | IF (INTA.GE.225 .AND. INTA.LE.250) INTA = INTA - 32 77 | IF (INTB.GE.225 .AND. INTB.LE.250) INTB = INTB - 32 78 | END IF 79 | LSAME = INTA .EQ. INTB 80 | * 81 | * RETURN 82 | * 83 | * End of LSAME 84 | * 85 | END 86 | -------------------------------------------------------------------------------- /blas/BLAS/xerbla.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE XERBLA(SRNAME,INFO) 2 | * 3 | * -- LAPACK auxiliary routine (preliminary version) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | INTEGER INFO 9 | CHARACTER*6 SRNAME 10 | * .. 11 | * 12 | * Purpose 13 | * ======= 14 | * 15 | * XERBLA is an error handler for the LAPACK routines. 16 | * It is called by an LAPACK routine if an input parameter has an 17 | * invalid value. A message is printed and execution stops. 18 | * 19 | * Installers may consider modifying the STOP statement in order to 20 | * call system-specific exception-handling facilities. 21 | * 22 | * Arguments 23 | * ========= 24 | * 25 | * SRNAME (input) CHARACTER*6 26 | * The name of the routine which called XERBLA. 27 | * 28 | * INFO (input) INTEGER 29 | * The position of the invalid parameter in the parameter list 30 | * of the calling routine. 31 | * 32 | * 33 | WRITE (*,FMT=9999) SRNAME,INFO 34 | * 35 | STOP 36 | * 37 | 9999 FORMAT (' ** On entry to ',A6,' parameter number ',I2,' had ', 38 | + 'an illegal value') 39 | * 40 | * End of XERBLA 41 | * 42 | END 43 | -------------------------------------------------------------------------------- /builddocs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # To run the following correctly, you will need a patched version of docutils to enable support for 3 | # math directives. 4 | # There is a dummy module in docs named distributions.py that imports all the PyMC likelihoods. 5 | # By introspection, epydoc finds the related docstrings and creates a tex output. This way, 6 | # we avoid documenting all the stuff that lives in the real pymc.distributions.py 7 | 8 | # epydoc --verbose --debug --config epydoc.conf 9 | 10 | 11 | # Make manual 12 | cd docs 13 | 14 | #cat distributions-module.tex | ./extract.py -s '\\subsection\{Functions\}' -o distributions-module.text 15 | #sed -i -e 's/0\.5\\fboxrule/1pt/g' distributions-module.tex 16 | 17 | python rst2latex.py ../README.rst --use-latex-toc --no-section-numbering | ./extract.py -s '%___________________________________________________________________________' -e '\\end\{document\}' -o README.tex 18 | python rst2latex.py ../INSTALL.rst --use-latex-toc --no-section-numbering | ./extract.py -s '%___________________________________________________________________________' -e '\\end\{document\}' -o INSTALL.tex 19 | python rst2latex.py ../pymc/database/README.txt --use-latex-toc --no-section-numbering | ./extract.py -s '%___________________________________________________________________________' -e '\\end\{document\}' -o database.tex 20 | 21 | mkdir pdf 22 | # User Guide 23 | pdflatex -output-directory=pdf -interaction batchmode UserGuide 24 | bibtex pdf/UserGuide 25 | pdflatex -output-directory=pdf -interaction batchmode UserGuide 26 | pdflatex -output-directory=pdf -interaction batchmode UserGuide 27 | cp pdf/UserGuide.pdf . 28 | 29 | cd .. 30 | -------------------------------------------------------------------------------- /builddpkg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | python setupegg.py sdist_dsc --extra-cfg-file stdeb_all.cfg 4 | cd deb_dist/pymc-2.0 5 | dpkg-buildpackage -rfakeroot -uc -us 6 | -------------------------------------------------------------------------------- /buildosx: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export CFLAGS="-arch x86_64" 3 | export FFLAGS="-static -ff2c -arch x86_64" 4 | export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch x86_64" 5 | rm -rf build 6 | python setupegg.py bdist_egg 7 | # sudo python setupegg.py develop 8 | -------------------------------------------------------------------------------- /cephes/README: -------------------------------------------------------------------------------- 1 | These files were copied from the scipy/special/cephes directory with 2 | the exception of the c2f.c file on 2009-01-13 by Andrew D. Straw. 3 | 4 | Accordingly, these files (all but c2f.c) are under the following 5 | license, which was copied from scipy/LICENSE.txt. 6 | 7 | Copyright (c) 2001, 2002 Enthought, Inc. 8 | 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | a. Redistributions of source code must retain the above copyright notice, 15 | this list of conditions and the following disclaimer. 16 | b. Redistributions in binary form must reproduce the above copyright 17 | notice, this list of conditions and the following disclaimer in the 18 | documentation and/or other materials provided with the distribution. 19 | c. Neither the name of the Enthought nor the names of its contributors 20 | may be used to endorse or promote products derived from this software 21 | without specific prior written permission. 22 | 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR 28 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 34 | DAMAGE. 35 | 36 | -------------------------------------------------------------------------------- /cephes/c2f.c: -------------------------------------------------------------------------------- 1 | /* c2f.c - call C functions from fortran */ 2 | 3 | /* Fortran and C have different calling conventions. This file does 4 | impedance matching between the two. */ 5 | 6 | extern double cephes_i0(double); 7 | 8 | double i0_(x) 9 | double* x; 10 | { 11 | double result; 12 | result = cephes_i0(*x); 13 | return result; 14 | } 15 | -------------------------------------------------------------------------------- /cephes/chbevl.c: -------------------------------------------------------------------------------- 1 | /* chbevl.c 2 | * 3 | * Evaluate Chebyshev series 4 | * 5 | * 6 | * 7 | * SYNOPSIS: 8 | * 9 | * int N; 10 | * double x, y, coef[N], chebevl(); 11 | * 12 | * y = chbevl( x, coef, N ); 13 | * 14 | * 15 | * 16 | * DESCRIPTION: 17 | * 18 | * Evaluates the series 19 | * 20 | * N-1 21 | * - ' 22 | * y = > coef[i] T (x/2) 23 | * - i 24 | * i=0 25 | * 26 | * of Chebyshev polynomials Ti at argument x/2. 27 | * 28 | * Coefficients are stored in reverse order, i.e. the zero 29 | * order term is last in the array. Note N is the number of 30 | * coefficients, not the order. 31 | * 32 | * If coefficients are for the interval a to b, x must 33 | * have been transformed to x -> 2(2x - b - a)/(b-a) before 34 | * entering the routine. This maps x from (a, b) to (-1, 1), 35 | * over which the Chebyshev polynomials are defined. 36 | * 37 | * If the coefficients are for the inverted interval, in 38 | * which (a, b) is mapped to (1/b, 1/a), the transformation 39 | * required is x -> 2(2ab/x - b - a)/(b-a). If b is infinity, 40 | * this becomes x -> 4a/x - 1. 41 | * 42 | * 43 | * 44 | * SPEED: 45 | * 46 | * Taking advantage of the recurrence properties of the 47 | * Chebyshev polynomials, the routine requires one more 48 | * addition per loop than evaluating a nested polynomial of 49 | * the same degree. 50 | * 51 | */ 52 | /* chbevl.c */ 53 | 54 | /* 55 | Cephes Math Library Release 2.0: April, 1987 56 | Copyright 1985, 1987 by Stephen L. Moshier 57 | Direct inquiries to 30 Frost Street, Cambridge, MA 02140 58 | */ 59 | 60 | #include 61 | 62 | #define ANSIPROT 63 | #ifdef ANSIPROT 64 | double chbevl( double, double [], int ); 65 | #endif 66 | 67 | double chbevl( x, array, n ) 68 | double x; 69 | double array[]; 70 | int n; 71 | { 72 | double b0, b1, b2, *p; 73 | int i; 74 | 75 | p = array; 76 | b0 = *p++; 77 | b1 = 0.0; 78 | i = n - 1; 79 | 80 | do 81 | { 82 | b2 = b1; 83 | b1 = b0; 84 | b0 = x * b1 - b2 + *p++; 85 | } 86 | while( --i ); 87 | 88 | return( 0.5*(b0-b2) ); 89 | } 90 | -------------------------------------------------------------------------------- /code_maintenance.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import pymc 4 | import os 5 | 6 | # This is a function, not a test case, because it has to be run from inside 7 | # the source tree to work well. 8 | 9 | mod_strs = ['IPython', 'pylab', 'matplotlib', 'scipy','Pdb'] 10 | 11 | dep_files = {} 12 | for mod_str in mod_strs: 13 | dep_files[mod_str] = [] 14 | 15 | def remove_whitespace(fname): 16 | # Remove trailing whitespace 17 | fd = open(fname,mode='U') # open in universal newline mode 18 | lines = [] 19 | for line in fd.readlines(): 20 | lines.append( line.rstrip() ) 21 | fd.close() 22 | 23 | fd = open(fname,mode='w') 24 | fd.seek(0) 25 | for line in lines: 26 | fd.write(line+'\n') 27 | fd.close() 28 | # print 'Removed whitespace from %s'%fname 29 | 30 | # print 31 | 32 | # ==================== 33 | # = Strip whitespace = 34 | # ==================== 35 | for dirname, dirs, files in os.walk('.'): 36 | if dirname[1:].find('.')==-1: 37 | # print dirname 38 | for fname in files: 39 | if fname[-2:] in ['c', 'f'] or fname[-3:]=='.py' or fname[-4:] in ['.pyx', '.txt', '.tex', '.sty', '.cls'] or fname.find('.')==-1: 40 | # print fname 41 | remove_whitespace(dirname + '/' + fname) 42 | 43 | # ========================== 44 | # = Check for dependencies = 45 | # ========================== 46 | for dirname, dirs, files in os.walk('pymc'): 47 | for fname in files: 48 | if fname[-3:]=='.py' or fname[-4:]=='.pyx': 49 | if dirname.find('sandbox')==-1 and fname != 'test_dependencies.py'\ 50 | and dirname.find('examples')==-1: 51 | for mod_str in mod_strs: 52 | if file(dirname+'/'+fname).read().find(mod_str)>=0: 53 | dep_files[mod_str].append(dirname+'/'+fname) 54 | 55 | 56 | print 'Instances of optional dependencies found are:' 57 | for mod_str in mod_strs: 58 | print '\t'+mod_str+':' 59 | for fname in dep_files[mod_str]: 60 | print '\t\t'+fname 61 | if len(dep_files['Pdb'])>0: 62 | raise ValueError, 'Looks like Pdb was not commented out in '+', '.join(dep_files[mod_str]) 63 | 64 | 65 | -------------------------------------------------------------------------------- /conda/bld.bat: -------------------------------------------------------------------------------- 1 | %SYS_PYTHON% setup.py build --compiler=mingw32 2 | %SYS_PYTHON% setup.py install --prefix=%PREFIX% 3 | if errorlevel 1 exit 1 4 | 5 | 6 | for %%x in (libgcc_s_sjlj-1.dll libgfortran-3.dll libquadmath-0.dll) do ( 7 | copy %SYS_PREFIX%\Scripts\%%x %SP_DIR%\pymc\ 8 | if errorlevel 1 exit 1 9 | ) 10 | -------------------------------------------------------------------------------- /conda/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ "$(uname)" == "Darwin" ]; then 3 | # export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch x86_64" 4 | cp /usr/local/Cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/libgfortran*.*a . 5 | LDFLAGS="-undefined dynamic_lookup -bundle -Wl,-search_paths_first -L$(pwd) $LDFLAGS" 6 | fi 7 | 8 | $PYTHON setup.py build 9 | $PYTHON setup.py install 10 | -------------------------------------------------------------------------------- /conda/meta.yaml: -------------------------------------------------------------------------------- 1 | package: 2 | name: pymc 3 | version: 2.3.8 4 | 5 | requirements: 6 | build: 7 | - python 8 | - numpy 9 | 10 | run: 11 | - python 12 | - numpy 13 | - matplotlib 14 | - scipy 15 | 16 | test: 17 | imports: 18 | - pymc 19 | 20 | requires: 21 | - nose 22 | 23 | about: 24 | home: https://github.com/pymc-devs/pymc 25 | license: Academic Free License (http://opensource.org/licenses/AFL-3.0) 26 | -------------------------------------------------------------------------------- /conda/run_test.py: -------------------------------------------------------------------------------- 1 | import pymc 2 | import pymc.Container_values 3 | import pymc.LazyFunction 4 | import pymc.flib 5 | import pymc.gp.cov_funs.distances 6 | import pymc.gp.cov_funs.isotropic_cov_funs 7 | import pymc.gp.incomplete_chol 8 | import pymc.gp.linalg_utils 9 | -------------------------------------------------------------------------------- /devtools/build-vm/linux/build_conda_package_vagrant.sh: -------------------------------------------------------------------------------- 1 | export PATH=$HOME/miniconda/bin:$PATH 2 | 3 | git clone https://github.com/pymc-devs/pymc.git 4 | cd pymc 5 | git checkout tags/2.3.4 # To checkout specific release for packaging. 6 | conda build conda 7 | -------------------------------------------------------------------------------- /devtools/build-vm/linux/setup_centos_vm.sh: -------------------------------------------------------------------------------- 1 | # Prepare a vagrant CentOS 6.5 VM for building OpenMM 2 | # Needs latest version of vagrant to auto-download the chef package 3 | #vagrant init chef/centos-6.5 4 | #vagrant up 5 | #vagrant ssh 6 | 7 | 8 | # Download and enable the EPEL RedHat EL extras repository 9 | mkdir ~/Software 10 | cd Software 11 | sudo yum install wget -y 12 | wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm 13 | sudo rpm -i epel-release-6-8.noarch.rpm 14 | 15 | sudo yum update -y 16 | 17 | # Several of these come from the EPEL repo 18 | sudo yum install cmake28 graphviz perl flex bison rpm-build texlive texlive-latex ghostscript gcc gcc-c++ git vim -y gcc-gfortran 19 | 20 | # Probably can't use RHEL6 version of doxygen because it's very old. 21 | wget http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.7.src.tar.gz 22 | rpmbuild -ta doxygen-1.8.7.src.tar.gz 23 | sudo rpm -i ~/rpmbuild/RPMS/x86_64/doxygen-1.8.7-1.x86_64.rpm 24 | rm ~/rpmbuild -r 25 | 26 | 27 | sudo yum clean headers 28 | sudo yum clean packages 29 | 30 | 31 | # Install Conda 32 | cd ~/Software 33 | wget http://repo.continuum.io/miniconda/Miniconda-3.7.0-Linux-x86_64.sh 34 | bash Miniconda-3.7.0-Linux-x86_64.sh -b 35 | 36 | export PATH=$HOME/miniconda/bin:$PATH 37 | conda install --yes jinja2 sphinx conda-build binstar 38 | -------------------------------------------------------------------------------- /docs/_images/DisasterModel2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/DisasterModel2.pdf -------------------------------------------------------------------------------- /docs/_images/DisasterModel2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/DisasterModel2.png -------------------------------------------------------------------------------- /docs/_images/PotExample.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/PotExample.pdf -------------------------------------------------------------------------------- /docs/_images/PotExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/PotExample.png -------------------------------------------------------------------------------- /docs/_images/autocorr.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/autocorr.pdf -------------------------------------------------------------------------------- /docs/_images/autocorr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/autocorr.png -------------------------------------------------------------------------------- /docs/_images/deviates.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/deviates.pdf -------------------------------------------------------------------------------- /docs/_images/deviates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/deviates.png -------------------------------------------------------------------------------- /docs/_images/disasterts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/disasterts.pdf -------------------------------------------------------------------------------- /docs/_images/disasterts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/disasterts.png -------------------------------------------------------------------------------- /docs/_images/envelope.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/envelope.pdf -------------------------------------------------------------------------------- /docs/_images/envelope.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/envelope.png -------------------------------------------------------------------------------- /docs/_images/geweke.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/geweke.pdf -------------------------------------------------------------------------------- /docs/_images/geweke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/geweke.png -------------------------------------------------------------------------------- /docs/_images/gof.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/gof.pdf -------------------------------------------------------------------------------- /docs/_images/gof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/gof.png -------------------------------------------------------------------------------- /docs/_images/icon.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/icon.pdf -------------------------------------------------------------------------------- /docs/_images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/icon.png -------------------------------------------------------------------------------- /docs/_images/ltrace.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/ltrace.pdf -------------------------------------------------------------------------------- /docs/_images/ltrace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/ltrace.png -------------------------------------------------------------------------------- /docs/_images/metastable.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/metastable.pdf -------------------------------------------------------------------------------- /docs/_images/metastable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/metastable.png -------------------------------------------------------------------------------- /docs/_images/missing.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/missing.pdf -------------------------------------------------------------------------------- /docs/_images/missing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/missing.png -------------------------------------------------------------------------------- /docs/_images/poormixing.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/poormixing.pdf -------------------------------------------------------------------------------- /docs/_images/poormixing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/poormixing.png -------------------------------------------------------------------------------- /docs/_images/reject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/reject.pdf -------------------------------------------------------------------------------- /docs/_images/reject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/reject.png -------------------------------------------------------------------------------- /docs/_images/spost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/spost.pdf -------------------------------------------------------------------------------- /docs/_images/spost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/spost.png -------------------------------------------------------------------------------- /docs/_images/summary.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/summary.pdf -------------------------------------------------------------------------------- /docs/_images/summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/summary.png -------------------------------------------------------------------------------- /docs/_images/write_csv.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/write_csv.pdf -------------------------------------------------------------------------------- /docs/_images/write_csv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/docs/_images/write_csv.png -------------------------------------------------------------------------------- /docs/conclusion.rst: -------------------------------------------------------------------------------- 1 | ********** 2 | Conclusion 3 | ********** 4 | 5 | MCMC is a surprisingly difficult and bug-prone algorithm to implement by hand. 6 | We find PyMC makes it much easier and less stressful. PyMC also makes our work 7 | more dynamic; getting hand-coded MCMC's working used to be so much work that we 8 | were reluctant to change anything, but with PyMC changing models is much easier. 9 | 10 | We welcome new contributors at all levels. If you would like to contribute new 11 | code, improve documentation, share your results or provide ideas for new 12 | features, please introduce yourself on our `mailing list`_. Our `wiki page`_. 13 | also hosts a number of tutorials and examples from users that could give you 14 | some ideas. We have taken great care to make the code easy to extend, whether 15 | by adding new database backends, step methods or entirely new sampling 16 | algorithms. 17 | 18 | .. _`mailing list`: pymc@googlegroups.com 19 | 20 | .. _`wiki page`: https://github.com/pymc-devs/pymc/wiki 21 | 22 | 23 | **************** 24 | Acknowledgements 25 | **************** 26 | 27 | The authors would like to thank several users of PyMC who have been 28 | particularly helpful during the development of the 2.0 release. In alphabetical 29 | order, these are Mike Conroy, Abraham Flaxman, J. Miguel Marin, Aaron MacNeil, 30 | Nick Matsakis, John Salvatier, Andrew Straw and Thomas Wiecki. 31 | 32 | Anand Patil’s work on PyMC has been supported since 2008 by the Malaria Atlas 33 | Project, principally funded by the Wellcome Trust. 34 | 35 | David Huard’s early work on PyMC was supported by a scholarship from the 36 | Natural Sciences and Engineering Research Council of Canada. 37 | -------------------------------------------------------------------------------- /docs/distributions.rst: -------------------------------------------------------------------------------- 1 | .. _chap_distributions: 2 | 3 | ************************* 4 | Probability distributions 5 | ************************* 6 | 7 | PyMC provides a large suite of built-in probability distributions. For each distribution, it provides: 8 | 9 | * A function that evaluates its log-probability or log-density: normal_like(). 10 | * A function that draws random variables: rnormal(). 11 | * A function that computes the expectation associated with the distribution: normal_expval(). 12 | * A Stochastic subclass generated from the distribution: Normal. 13 | 14 | This section describes the likelihood functions of these distributions. 15 | 16 | .. module:: pymc.distributions 17 | 18 | Discrete distributions 19 | ====================== 20 | 21 | .. autofunction:: bernoulli_like 22 | 23 | .. autofunction:: binomial_like 24 | 25 | .. autofunction:: categorical_like 26 | 27 | .. autofunction:: discrete_uniform_like 28 | 29 | .. autofunction:: geometric_like 30 | 31 | .. autofunction:: hypergeometric_like 32 | 33 | .. autofunction:: negative_binomial_like 34 | 35 | .. autofunction:: poisson_like 36 | 37 | .. autofunction:: truncated_poisson_like 38 | 39 | 40 | Continuous distributions 41 | ======================== 42 | 43 | .. autofunction:: beta_like 44 | 45 | .. autofunction:: cauchy_like 46 | 47 | .. autofunction:: chi2_like 48 | 49 | .. autofunction:: degenerate_like 50 | 51 | .. autofunction:: exponential_like 52 | 53 | .. autofunction:: exponweib_like 54 | 55 | .. autofunction:: gamma_like 56 | 57 | .. autofunction:: half_cauchy_like 58 | 59 | .. autofunction:: half_normal_like 60 | 61 | .. autofunction:: inverse_gamma_like 62 | 63 | .. autofunction:: laplace_like 64 | 65 | .. autofunction:: logistic_like 66 | 67 | .. autofunction:: lognormal_like 68 | 69 | .. autofunction:: noncentral_t_like 70 | 71 | .. autofunction:: normal_like 72 | 73 | .. autofunction:: pareto_like 74 | 75 | .. autofunction:: skew_normal_like 76 | 77 | .. autofunction:: t_like 78 | 79 | .. autofunction:: truncated_normal_like 80 | 81 | .. autofunction:: truncated_pareto_like 82 | 83 | .. autofunction:: uniform_like 84 | 85 | .. autofunction:: von_mises_like 86 | 87 | .. autofunction:: weibull_like 88 | 89 | 90 | Multivariate discrete distributions 91 | =================================== 92 | 93 | .. autofunction:: multivariate_hypergeometric_like 94 | 95 | .. autofunction:: multinomial_like 96 | 97 | 98 | Multivariate continuous distributions 99 | ===================================== 100 | 101 | .. autofunction:: dirichlet_like 102 | 103 | .. autofunction:: mv_normal_like 104 | 105 | .. autofunction:: mv_normal_chol_like 106 | 107 | .. autofunction:: mv_normal_cov_like 108 | 109 | .. autofunction:: wishart_like 110 | 111 | .. autofunction:: wishart_cov_like 112 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. PyMC documentation master file, created by sphinx-quickstart on Tue Jan 25 12:00:55 2011. 2 | 3 | PyMC User's Guide 4 | ================= 5 | 6 | **CAUTION**: This is the **old** PyMC project. Please **use PyMC3 instead**: ``_ 7 | 8 | Contents: 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | :numbered: 13 | 14 | README 15 | INSTALL 16 | tutorial 17 | modelbuilding 18 | modelfitting 19 | database 20 | modelchecking 21 | extending 22 | distributions 23 | conclusion 24 | theory 25 | references 26 | 27 | Indices and tables 28 | ================== 29 | 30 | * :ref:`genindex` 31 | * :ref:`modindex` 32 | * :ref:`search` 33 | 34 | -------------------------------------------------------------------------------- /lapack/double/disnan.f: -------------------------------------------------------------------------------- 1 | LOGICAL FUNCTION DISNAN(DIN) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | DOUBLE PRECISION DIN 9 | * .. 10 | * 11 | * Purpose 12 | * ======= 13 | * 14 | * DISNAN returns .TRUE. if its argument is NaN, and .FALSE. 15 | * otherwise. To be replaced by the Fortran 2003 intrinsic in the 16 | * future. 17 | * 18 | * Arguments 19 | * ========= 20 | * 21 | * DIN (input) DOUBLE PRECISION 22 | * Input to test for NaN. 23 | * 24 | * ===================================================================== 25 | * 26 | * .. External Functions .. 27 | LOGICAL DLAISNAN 28 | EXTERNAL DLAISNAN 29 | * .. 30 | * .. Executable Statements .. 31 | DISNAN = DLAISNAN(DIN,DIN) 32 | RETURN 33 | END 34 | -------------------------------------------------------------------------------- /lapack/double/dlabad.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DLABAD( SMALL, LARGE ) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | DOUBLE PRECISION LARGE, SMALL 9 | * .. 10 | * 11 | * Purpose 12 | * ======= 13 | * 14 | * DLABAD takes as input the values computed by DLAMCH for underflow and 15 | * overflow, and returns the square root of each of these values if the 16 | * log of LARGE is sufficiently large. This subroutine is intended to 17 | * identify machines with a large exponent range, such as the Crays, and 18 | * redefine the underflow and overflow limits to be the square roots of 19 | * the values computed by DLAMCH. This subroutine is needed because 20 | * DLAMCH does not compensate for poor arithmetic in the upper half of 21 | * the exponent range, as is found on a Cray. 22 | * 23 | * Arguments 24 | * ========= 25 | * 26 | * SMALL (input/output) DOUBLE PRECISION 27 | * On entry, the underflow threshold as computed by DLAMCH. 28 | * On exit, if LOG10(LARGE) is sufficiently large, the square 29 | * root of SMALL, otherwise unchanged. 30 | * 31 | * LARGE (input/output) DOUBLE PRECISION 32 | * On entry, the overflow threshold as computed by DLAMCH. 33 | * On exit, if LOG10(LARGE) is sufficiently large, the square 34 | * root of LARGE, otherwise unchanged. 35 | * 36 | * ===================================================================== 37 | * 38 | * .. Intrinsic Functions .. 39 | INTRINSIC LOG10, SQRT 40 | * .. 41 | * .. Executable Statements .. 42 | * 43 | * If it looks like we're on a Cray, take the square root of 44 | * SMALL and LARGE to avoid overflow and underflow problems. 45 | * 46 | IF( LOG10( LARGE ).GT.2000.D0 ) THEN 47 | SMALL = SQRT( SMALL ) 48 | LARGE = SQRT( LARGE ) 49 | END IF 50 | * 51 | RETURN 52 | * 53 | * End of DLABAD 54 | * 55 | END 56 | -------------------------------------------------------------------------------- /lapack/double/dlacpy.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DLACPY( UPLO, M, N, A, LDA, B, LDB ) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | CHARACTER UPLO 9 | INTEGER LDA, LDB, M, N 10 | * .. 11 | * .. Array Arguments .. 12 | DOUBLE PRECISION A( LDA, * ), B( LDB, * ) 13 | * .. 14 | * 15 | * Purpose 16 | * ======= 17 | * 18 | * DLACPY copies all or part of a two-dimensional matrix A to another 19 | * matrix B. 20 | * 21 | * Arguments 22 | * ========= 23 | * 24 | * UPLO (input) CHARACTER*1 25 | * Specifies the part of the matrix A to be copied to B. 26 | * = 'U': Upper triangular part 27 | * = 'L': Lower triangular part 28 | * Otherwise: All of the matrix A 29 | * 30 | * M (input) INTEGER 31 | * The number of rows of the matrix A. M >= 0. 32 | * 33 | * N (input) INTEGER 34 | * The number of columns of the matrix A. N >= 0. 35 | * 36 | * A (input) DOUBLE PRECISION array, dimension (LDA,N) 37 | * The m by n matrix A. If UPLO = 'U', only the upper triangle 38 | * or trapezoid is accessed; if UPLO = 'L', only the lower 39 | * triangle or trapezoid is accessed. 40 | * 41 | * LDA (input) INTEGER 42 | * The leading dimension of the array A. LDA >= max(1,M). 43 | * 44 | * B (output) DOUBLE PRECISION array, dimension (LDB,N) 45 | * On exit, B = A in the locations specified by UPLO. 46 | * 47 | * LDB (input) INTEGER 48 | * The leading dimension of the array B. LDB >= max(1,M). 49 | * 50 | * ===================================================================== 51 | * 52 | * .. Local Scalars .. 53 | INTEGER I, J 54 | * .. 55 | * .. External Functions .. 56 | LOGICAL LSAME 57 | EXTERNAL LSAME 58 | * .. 59 | * .. Intrinsic Functions .. 60 | INTRINSIC MIN 61 | * .. 62 | * .. Executable Statements .. 63 | * 64 | IF( LSAME( UPLO, 'U' ) ) THEN 65 | DO 20 J = 1, N 66 | DO 10 I = 1, MIN( J, M ) 67 | B( I, J ) = A( I, J ) 68 | 10 CONTINUE 69 | 20 CONTINUE 70 | ELSE IF( LSAME( UPLO, 'L' ) ) THEN 71 | DO 40 J = 1, N 72 | DO 30 I = J, M 73 | B( I, J ) = A( I, J ) 74 | 30 CONTINUE 75 | 40 CONTINUE 76 | ELSE 77 | DO 60 J = 1, N 78 | DO 50 I = 1, M 79 | B( I, J ) = A( I, J ) 80 | 50 CONTINUE 81 | 60 CONTINUE 82 | END IF 83 | RETURN 84 | * 85 | * End of DLACPY 86 | * 87 | END 88 | -------------------------------------------------------------------------------- /lapack/double/dladiv.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DLADIV( A, B, C, D, P, Q ) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | DOUBLE PRECISION A, B, C, D, P, Q 9 | * .. 10 | * 11 | * Purpose 12 | * ======= 13 | * 14 | * DLADIV performs complex division in real arithmetic 15 | * 16 | * a + i*b 17 | * p + i*q = --------- 18 | * c + i*d 19 | * 20 | * The algorithm is due to Robert L. Smith and can be found 21 | * in D. Knuth, The art of Computer Programming, Vol.2, p.195 22 | * 23 | * Arguments 24 | * ========= 25 | * 26 | * A (input) DOUBLE PRECISION 27 | * B (input) DOUBLE PRECISION 28 | * C (input) DOUBLE PRECISION 29 | * D (input) DOUBLE PRECISION 30 | * The scalars a, b, c, and d in the above expression. 31 | * 32 | * P (output) DOUBLE PRECISION 33 | * Q (output) DOUBLE PRECISION 34 | * The scalars p and q in the above expression. 35 | * 36 | * ===================================================================== 37 | * 38 | * .. Local Scalars .. 39 | DOUBLE PRECISION E, F 40 | * .. 41 | * .. Intrinsic Functions .. 42 | INTRINSIC ABS 43 | * .. 44 | * .. Executable Statements .. 45 | * 46 | IF( ABS( D ).LT.ABS( C ) ) THEN 47 | E = D / C 48 | F = C + D*E 49 | P = ( A+B*E ) / F 50 | Q = ( B-A*E ) / F 51 | ELSE 52 | E = C / D 53 | F = D + C*E 54 | P = ( B+A*E ) / F 55 | Q = ( -A+B*E ) / F 56 | END IF 57 | * 58 | RETURN 59 | * 60 | * End of DLADIV 61 | * 62 | END 63 | -------------------------------------------------------------------------------- /lapack/double/dlag2s.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DLAG2S( M, N, A, LDA, SA, LDSA, INFO) 2 | * 3 | * -- LAPACK PROTOTYPE auxiliary routine (version 3.1.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * January 2007 6 | * 7 | * .. 8 | * .. WARNING: PROTOTYPE .. 9 | * This is an LAPACK PROTOTYPE routine which means that the 10 | * interface of this routine is likely to be changed in the future 11 | * based on community feedback. 12 | * 13 | * .. Scalar Arguments .. 14 | INTEGER INFO,LDA,LDSA,M,N 15 | * .. 16 | * .. Array Arguments .. 17 | REAL SA(LDSA,*) 18 | DOUBLE PRECISION A(LDA,*) 19 | * .. 20 | * 21 | * Purpose 22 | * ======= 23 | * 24 | * DLAG2S converts a DOUBLE PRECISION matrix, SA, to a SINGLE 25 | * PRECISION matrix, A. 26 | * 27 | * RMAX is the overflow for the SINGLE PRECISION arithmetic 28 | * DLAG2S checks that all the entries of A are between -RMAX and 29 | * RMAX. If not the convertion is aborted and a flag is raised. 30 | * 31 | * This is a helper routine so there is no argument checking. 32 | * 33 | * Arguments 34 | * ========= 35 | * 36 | * M (input) INTEGER 37 | * The number of lines of the matrix A. M >= 0. 38 | * 39 | * N (input) INTEGER 40 | * The number of columns of the matrix A. N >= 0. 41 | * 42 | * A (input) DOUBLE PRECISION array, dimension (LDA,N) 43 | * On entry, the M-by-N coefficient matrix A. 44 | * 45 | * LDA (input) INTEGER 46 | * The leading dimension of the array A. LDA >= max(1,M). 47 | * 48 | * SA (output) REAL array, dimension (LDSA,N) 49 | * On exit, if INFO=0, the M-by-N coefficient matrix SA. 50 | * 51 | * LDSA (input) INTEGER 52 | * The leading dimension of the array SA. LDSA >= max(1,M). 53 | * 54 | * INFO (output) INTEGER 55 | * = 0: successful exit 56 | * > 0: if INFO = k, the (i,j) entry of the matrix A has 57 | * overflowed when moving from DOUBLE PRECISION to SINGLE 58 | * k is given by k = (i-1)*LDA+j 59 | * 60 | * ========= 61 | * 62 | * .. Local Scalars .. 63 | INTEGER I,J 64 | DOUBLE PRECISION RMAX 65 | * .. 66 | * .. External Functions .. 67 | REAL SLAMCH 68 | EXTERNAL SLAMCH 69 | * .. 70 | * .. Executable Statements .. 71 | * 72 | RMAX = SLAMCH('O') 73 | DO 20 J = 1,N 74 | DO 30 I = 1,M 75 | IF ((A(I,J).LT.-RMAX) .OR. (A(I,J).GT.RMAX)) THEN 76 | INFO = (I-1)*LDA + J 77 | GO TO 10 78 | END IF 79 | SA(I,J) = A(I,J) 80 | 30 CONTINUE 81 | 20 CONTINUE 82 | 10 CONTINUE 83 | RETURN 84 | * 85 | * End of DLAG2S 86 | * 87 | END 88 | -------------------------------------------------------------------------------- /lapack/double/dlaisnan.f: -------------------------------------------------------------------------------- 1 | LOGICAL FUNCTION DLAISNAN(DIN1,DIN2) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | DOUBLE PRECISION DIN1,DIN2 9 | * .. 10 | * 11 | * Purpose 12 | * ======= 13 | * 14 | * This routine is not for general use. It exists solely to avoid 15 | * over-optimization in DISNAN. 16 | * 17 | * DLAISNAN checks for NaNs by comparing its two arguments for 18 | * inequality. NaN is the only floating-point value where NaN != NaN 19 | * returns .TRUE. To check for NaNs, pass the same variable as both 20 | * arguments. 21 | * 22 | * Strictly speaking, Fortran does not allow aliasing of function 23 | * arguments. So a compiler must assume that the two arguments are 24 | * not the same variable, and the test will not be optimized away. 25 | * Interprocedural or whole-program optimization may delete this 26 | * test. The ISNAN functions will be replaced by the correct 27 | * Fortran 03 intrinsic once the intrinsic is widely available. 28 | * 29 | * Arguments 30 | * ========= 31 | * 32 | * DIN1 (input) DOUBLE PRECISION 33 | * DIN2 (input) DOUBLE PRECISION 34 | * Two numbers to compare for inequality. 35 | * 36 | * ===================================================================== 37 | * 38 | * .. Executable Statements .. 39 | DLAISNAN = (DIN1.NE.DIN2) 40 | RETURN 41 | END 42 | -------------------------------------------------------------------------------- /lapack/double/dlapy2.f: -------------------------------------------------------------------------------- 1 | DOUBLE PRECISION FUNCTION DLAPY2( X, Y ) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | DOUBLE PRECISION X, Y 9 | * .. 10 | * 11 | * Purpose 12 | * ======= 13 | * 14 | * DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary 15 | * overflow. 16 | * 17 | * Arguments 18 | * ========= 19 | * 20 | * X (input) DOUBLE PRECISION 21 | * Y (input) DOUBLE PRECISION 22 | * X and Y specify the values x and y. 23 | * 24 | * ===================================================================== 25 | * 26 | * .. Parameters .. 27 | DOUBLE PRECISION ZERO 28 | PARAMETER ( ZERO = 0.0D0 ) 29 | DOUBLE PRECISION ONE 30 | PARAMETER ( ONE = 1.0D0 ) 31 | * .. 32 | * .. Local Scalars .. 33 | DOUBLE PRECISION W, XABS, YABS, Z 34 | * .. 35 | * .. Intrinsic Functions .. 36 | INTRINSIC ABS, MAX, MIN, SQRT 37 | * .. 38 | * .. Executable Statements .. 39 | * 40 | XABS = ABS( X ) 41 | YABS = ABS( Y ) 42 | W = MAX( XABS, YABS ) 43 | Z = MIN( XABS, YABS ) 44 | IF( Z.EQ.ZERO ) THEN 45 | DLAPY2 = W 46 | ELSE 47 | DLAPY2 = W*SQRT( ONE+( Z / W )**2 ) 48 | END IF 49 | RETURN 50 | * 51 | * End of DLAPY2 52 | * 53 | END 54 | -------------------------------------------------------------------------------- /lapack/double/dlapy3.f: -------------------------------------------------------------------------------- 1 | DOUBLE PRECISION FUNCTION DLAPY3( X, Y, Z ) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | DOUBLE PRECISION X, Y, Z 9 | * .. 10 | * 11 | * Purpose 12 | * ======= 13 | * 14 | * DLAPY3 returns sqrt(x**2+y**2+z**2), taking care not to cause 15 | * unnecessary overflow. 16 | * 17 | * Arguments 18 | * ========= 19 | * 20 | * X (input) DOUBLE PRECISION 21 | * Y (input) DOUBLE PRECISION 22 | * Z (input) DOUBLE PRECISION 23 | * X, Y and Z specify the values x, y and z. 24 | * 25 | * ===================================================================== 26 | * 27 | * .. Parameters .. 28 | DOUBLE PRECISION ZERO 29 | PARAMETER ( ZERO = 0.0D0 ) 30 | * .. 31 | * .. Local Scalars .. 32 | DOUBLE PRECISION W, XABS, YABS, ZABS 33 | * .. 34 | * .. Intrinsic Functions .. 35 | INTRINSIC ABS, MAX, SQRT 36 | * .. 37 | * .. Executable Statements .. 38 | * 39 | XABS = ABS( X ) 40 | YABS = ABS( Y ) 41 | ZABS = ABS( Z ) 42 | W = MAX( XABS, YABS, ZABS ) 43 | IF( W.EQ.ZERO ) THEN 44 | * W can be zero for max(0,nan,0) 45 | * adding all three entries together will make sure 46 | * NaN will not disappear. 47 | DLAPY3 = XABS + YABS + ZABS 48 | ELSE 49 | DLAPY3 = W*SQRT( ( XABS / W )**2+( YABS / W )**2+ 50 | $ ( ZABS / W )**2 ) 51 | END IF 52 | RETURN 53 | * 54 | * End of DLAPY3 55 | * 56 | END 57 | -------------------------------------------------------------------------------- /lapack/double/dlar2v.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DLAR2V( N, X, Y, Z, INCX, C, S, INCC ) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | INTEGER INCC, INCX, N 9 | * .. 10 | * .. Array Arguments .. 11 | DOUBLE PRECISION C( * ), S( * ), X( * ), Y( * ), Z( * ) 12 | * .. 13 | * 14 | * Purpose 15 | * ======= 16 | * 17 | * DLAR2V applies a vector of real plane rotations from both sides to 18 | * a sequence of 2-by-2 real symmetric matrices, defined by the elements 19 | * of the vectors x, y and z. For i = 1,2,...,n 20 | * 21 | * ( x(i) z(i) ) := ( c(i) s(i) ) ( x(i) z(i) ) ( c(i) -s(i) ) 22 | * ( z(i) y(i) ) ( -s(i) c(i) ) ( z(i) y(i) ) ( s(i) c(i) ) 23 | * 24 | * Arguments 25 | * ========= 26 | * 27 | * N (input) INTEGER 28 | * The number of plane rotations to be applied. 29 | * 30 | * X (input/output) DOUBLE PRECISION array, 31 | * dimension (1+(N-1)*INCX) 32 | * The vector x. 33 | * 34 | * Y (input/output) DOUBLE PRECISION array, 35 | * dimension (1+(N-1)*INCX) 36 | * The vector y. 37 | * 38 | * Z (input/output) DOUBLE PRECISION array, 39 | * dimension (1+(N-1)*INCX) 40 | * The vector z. 41 | * 42 | * INCX (input) INTEGER 43 | * The increment between elements of X, Y and Z. INCX > 0. 44 | * 45 | * C (input) DOUBLE PRECISION array, dimension (1+(N-1)*INCC) 46 | * The cosines of the plane rotations. 47 | * 48 | * S (input) DOUBLE PRECISION array, dimension (1+(N-1)*INCC) 49 | * The sines of the plane rotations. 50 | * 51 | * INCC (input) INTEGER 52 | * The increment between elements of C and S. INCC > 0. 53 | * 54 | * ===================================================================== 55 | * 56 | * .. Local Scalars .. 57 | INTEGER I, IC, IX 58 | DOUBLE PRECISION CI, SI, T1, T2, T3, T4, T5, T6, XI, YI, ZI 59 | * .. 60 | * .. Executable Statements .. 61 | * 62 | IX = 1 63 | IC = 1 64 | DO 10 I = 1, N 65 | XI = X( IX ) 66 | YI = Y( IX ) 67 | ZI = Z( IX ) 68 | CI = C( IC ) 69 | SI = S( IC ) 70 | T1 = SI*ZI 71 | T2 = CI*ZI 72 | T3 = T2 - SI*XI 73 | T4 = T2 + SI*YI 74 | T5 = CI*XI + T1 75 | T6 = CI*YI - T1 76 | X( IX ) = CI*T5 + SI*T4 77 | Y( IX ) = CI*T6 - SI*T3 78 | Z( IX ) = CI*T4 - SI*T5 79 | IX = IX + INCX 80 | IC = IC + INCC 81 | 10 CONTINUE 82 | * 83 | * End of DLAR2V 84 | * 85 | RETURN 86 | END 87 | -------------------------------------------------------------------------------- /lapack/double/dlartv.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE DLARTV( N, X, INCX, Y, INCY, C, S, INCC ) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | INTEGER INCC, INCX, INCY, N 9 | * .. 10 | * .. Array Arguments .. 11 | DOUBLE PRECISION C( * ), S( * ), X( * ), Y( * ) 12 | * .. 13 | * 14 | * Purpose 15 | * ======= 16 | * 17 | * DLARTV applies a vector of real plane rotations to elements of the 18 | * real vectors x and y. For i = 1,2,...,n 19 | * 20 | * ( x(i) ) := ( c(i) s(i) ) ( x(i) ) 21 | * ( y(i) ) ( -s(i) c(i) ) ( y(i) ) 22 | * 23 | * Arguments 24 | * ========= 25 | * 26 | * N (input) INTEGER 27 | * The number of plane rotations to be applied. 28 | * 29 | * X (input/output) DOUBLE PRECISION array, 30 | * dimension (1+(N-1)*INCX) 31 | * The vector x. 32 | * 33 | * INCX (input) INTEGER 34 | * The increment between elements of X. INCX > 0. 35 | * 36 | * Y (input/output) DOUBLE PRECISION array, 37 | * dimension (1+(N-1)*INCY) 38 | * The vector y. 39 | * 40 | * INCY (input) INTEGER 41 | * The increment between elements of Y. INCY > 0. 42 | * 43 | * C (input) DOUBLE PRECISION array, dimension (1+(N-1)*INCC) 44 | * The cosines of the plane rotations. 45 | * 46 | * S (input) DOUBLE PRECISION array, dimension (1+(N-1)*INCC) 47 | * The sines of the plane rotations. 48 | * 49 | * INCC (input) INTEGER 50 | * The increment between elements of C and S. INCC > 0. 51 | * 52 | * ===================================================================== 53 | * 54 | * .. Local Scalars .. 55 | INTEGER I, IC, IX, IY 56 | DOUBLE PRECISION XI, YI 57 | * .. 58 | * .. Executable Statements .. 59 | * 60 | IX = 1 61 | IY = 1 62 | IC = 1 63 | DO 10 I = 1, N 64 | XI = X( IX ) 65 | YI = Y( IY ) 66 | X( IX ) = C( IC )*XI + S( IC )*YI 67 | Y( IY ) = C( IC )*YI - S( IC )*XI 68 | IX = IX + INCX 69 | IY = IY + INCY 70 | IC = IC + INCC 71 | 10 CONTINUE 72 | RETURN 73 | * 74 | * End of DLARTV 75 | * 76 | END 77 | -------------------------------------------------------------------------------- /lapack/double/dzsum1.f: -------------------------------------------------------------------------------- 1 | DOUBLE PRECISION FUNCTION DZSUM1( N, CX, INCX ) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | INTEGER INCX, N 9 | * .. 10 | * .. Array Arguments .. 11 | COMPLEX*16 CX( * ) 12 | * .. 13 | * 14 | * Purpose 15 | * ======= 16 | * 17 | * DZSUM1 takes the sum of the absolute values of a complex 18 | * vector and returns a double precision result. 19 | * 20 | * Based on DZASUM from the Level 1 BLAS. 21 | * The change is to use the 'genuine' absolute value. 22 | * 23 | * Contributed by Nick Higham for use with ZLACON. 24 | * 25 | * Arguments 26 | * ========= 27 | * 28 | * N (input) INTEGER 29 | * The number of elements in the vector CX. 30 | * 31 | * CX (input) COMPLEX*16 array, dimension (N) 32 | * The vector whose elements will be summed. 33 | * 34 | * INCX (input) INTEGER 35 | * The spacing between successive values of CX. INCX > 0. 36 | * 37 | * ===================================================================== 38 | * 39 | * .. Local Scalars .. 40 | INTEGER I, NINCX 41 | DOUBLE PRECISION STEMP 42 | * .. 43 | * .. Intrinsic Functions .. 44 | INTRINSIC ABS 45 | * .. 46 | * .. Executable Statements .. 47 | * 48 | DZSUM1 = 0.0D0 49 | STEMP = 0.0D0 50 | IF( N.LE.0 ) 51 | $ RETURN 52 | IF( INCX.EQ.1 ) 53 | $ GO TO 20 54 | * 55 | * CODE FOR INCREMENT NOT EQUAL TO 1 56 | * 57 | NINCX = N*INCX 58 | DO 10 I = 1, NINCX, INCX 59 | * 60 | * NEXT LINE MODIFIED. 61 | * 62 | STEMP = STEMP + ABS( CX( I ) ) 63 | 10 CONTINUE 64 | DZSUM1 = STEMP 65 | RETURN 66 | * 67 | * CODE FOR INCREMENT EQUAL TO 1 68 | * 69 | 20 CONTINUE 70 | DO 30 I = 1, N 71 | * 72 | * NEXT LINE MODIFIED. 73 | * 74 | STEMP = STEMP + ABS( CX( I ) ) 75 | 30 CONTINUE 76 | DZSUM1 = STEMP 77 | RETURN 78 | * 79 | * End of DZSUM1 80 | * 81 | END 82 | -------------------------------------------------------------------------------- /lapack/double/ilaver.f: -------------------------------------------------------------------------------- 1 | SUBROUTINE ILAVER( VERS_MAJOR, VERS_MINOR, VERS_PATCH ) 2 | * 3 | * -- LAPACK routine (version 3.1.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * January 2007 6 | * 7 | * .. Scalar Arguments .. 8 | INTEGER VERS_MAJOR, VERS_MINOR, VERS_PATCH 9 | * .. 10 | * 11 | * Purpose 12 | * ======= 13 | * 14 | * This subroutine return the Lapack version. 15 | * 16 | * Arguments 17 | * ========= 18 | * 19 | * VERS_MAJOR (output) INTEGER 20 | * return the lapack major version 21 | * VERS_MINOR (output) INTEGER 22 | * return the lapack minor version from the major version 23 | * VERS_PATCH (output) INTEGER 24 | * return the lapack patch version from the minor version 25 | * 26 | * .. Executable Statements .. 27 | * 28 | VERS_MAJOR = 3 29 | VERS_MINOR = 1 30 | VERS_PATCH = 1 31 | * ===================================================================== 32 | * 33 | RETURN 34 | END 35 | -------------------------------------------------------------------------------- /lapack/double/lsame.f: -------------------------------------------------------------------------------- 1 | LOGICAL FUNCTION LSAME( CA, CB ) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | CHARACTER CA, CB 9 | * .. 10 | * 11 | * Purpose 12 | * ======= 13 | * 14 | * LSAME returns .TRUE. if CA is the same letter as CB regardless of 15 | * case. 16 | * 17 | * Arguments 18 | * ========= 19 | * 20 | * CA (input) CHARACTER*1 21 | * CB (input) CHARACTER*1 22 | * CA and CB specify the single characters to be compared. 23 | * 24 | * ===================================================================== 25 | * 26 | * .. Intrinsic Functions .. 27 | INTRINSIC ICHAR 28 | * .. 29 | * .. Local Scalars .. 30 | INTEGER INTA, INTB, ZCODE 31 | * .. 32 | * .. Executable Statements .. 33 | * 34 | * Test if the characters are equal 35 | * 36 | LSAME = CA.EQ.CB 37 | IF( LSAME ) 38 | $ RETURN 39 | * 40 | * Now test for equivalence if both characters are alphabetic. 41 | * 42 | ZCODE = ICHAR( 'Z' ) 43 | * 44 | * Use 'Z' rather than 'A' so that ASCII can be detected on Prime 45 | * machines, on which ICHAR returns a value with bit 8 set. 46 | * ICHAR('A') on Prime machines returns 193 which is the same as 47 | * ICHAR('A') on an EBCDIC machine. 48 | * 49 | INTA = ICHAR( CA ) 50 | INTB = ICHAR( CB ) 51 | * 52 | IF( ZCODE.EQ.90 .OR. ZCODE.EQ.122 ) THEN 53 | * 54 | * ASCII is assumed - ZCODE is the ASCII code of either lower or 55 | * upper case 'Z'. 56 | * 57 | IF( INTA.GE.97 .AND. INTA.LE.122 ) INTA = INTA - 32 58 | IF( INTB.GE.97 .AND. INTB.LE.122 ) INTB = INTB - 32 59 | * 60 | ELSE IF( ZCODE.EQ.233 .OR. ZCODE.EQ.169 ) THEN 61 | * 62 | * EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or 63 | * upper case 'Z'. 64 | * 65 | IF( INTA.GE.129 .AND. INTA.LE.137 .OR. 66 | $ INTA.GE.145 .AND. INTA.LE.153 .OR. 67 | $ INTA.GE.162 .AND. INTA.LE.169 ) INTA = INTA + 64 68 | IF( INTB.GE.129 .AND. INTB.LE.137 .OR. 69 | $ INTB.GE.145 .AND. INTB.LE.153 .OR. 70 | $ INTB.GE.162 .AND. INTB.LE.169 ) INTB = INTB + 64 71 | * 72 | ELSE IF( ZCODE.EQ.218 .OR. ZCODE.EQ.250 ) THEN 73 | * 74 | * ASCII is assumed, on Prime machines - ZCODE is the ASCII code 75 | * plus 128 of either lower or upper case 'Z'. 76 | * 77 | IF( INTA.GE.225 .AND. INTA.LE.250 ) INTA = INTA - 32 78 | IF( INTB.GE.225 .AND. INTB.LE.250 ) INTB = INTB - 32 79 | END IF 80 | LSAME = INTA.EQ.INTB 81 | * 82 | * RETURN 83 | * 84 | * End of LSAME 85 | * 86 | END 87 | -------------------------------------------------------------------------------- /lapack/double/lsamen.f: -------------------------------------------------------------------------------- 1 | LOGICAL FUNCTION LSAMEN( N, CA, CB ) 2 | * 3 | * -- LAPACK auxiliary routine (version 3.1) -- 4 | * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 5 | * November 2006 6 | * 7 | * .. Scalar Arguments .. 8 | CHARACTER*( * ) CA, CB 9 | INTEGER N 10 | * .. 11 | * 12 | * Purpose 13 | * ======= 14 | * 15 | * LSAMEN tests if the first N letters of CA are the same as the 16 | * first N letters of CB, regardless of case. 17 | * LSAMEN returns .TRUE. if CA and CB are equivalent except for case 18 | * and .FALSE. otherwise. LSAMEN also returns .FALSE. if LEN( CA ) 19 | * or LEN( CB ) is less than N. 20 | * 21 | * Arguments 22 | * ========= 23 | * 24 | * N (input) INTEGER 25 | * The number of characters in CA and CB to be compared. 26 | * 27 | * CA (input) CHARACTER*(*) 28 | * CB (input) CHARACTER*(*) 29 | * CA and CB specify two character strings of length at least N. 30 | * Only the first N characters of each string will be accessed. 31 | * 32 | * ===================================================================== 33 | * 34 | * .. Local Scalars .. 35 | INTEGER I 36 | * .. 37 | * .. External Functions .. 38 | LOGICAL LSAME 39 | EXTERNAL LSAME 40 | * .. 41 | * .. Intrinsic Functions .. 42 | INTRINSIC LEN 43 | * .. 44 | * .. Executable Statements .. 45 | * 46 | LSAMEN = .FALSE. 47 | IF( LEN( CA ).LT.N .OR. LEN( CB ).LT.N ) 48 | $ GO TO 20 49 | * 50 | * Do for each character in the two strings. 51 | * 52 | DO 10 I = 1, N 53 | * 54 | * Test if the characters are equal using LSAME. 55 | * 56 | IF( .NOT.LSAME( CA( I: I ), CB( I: I ) ) ) 57 | $ GO TO 20 58 | * 59 | 10 CONTINUE 60 | LSAMEN = .TRUE. 61 | * 62 | 20 CONTINUE 63 | RETURN 64 | * 65 | * End of LSAMEN 66 | * 67 | END 68 | -------------------------------------------------------------------------------- /pymc-requirements: -------------------------------------------------------------------------------- 1 | pymc 2 | numpy>=1.8 3 | matplotlib>=0.9 4 | scipy>=0.8 5 | nose==0.11 6 | statsmodels>=0.5 7 | pydot -------------------------------------------------------------------------------- /pymc/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Markov Chain Monte Carlo sampling toolkit. 3 | 4 | Bayesian estimation, particularly using Markov chain Monte Carlo (MCMC), is an increasingly relevant approach to statistical estimation. However, few statistical software packages implement MCMC samplers, and they are non-trivial to code by hand. pymc is a python package that implements the Metropolis-Hastings algorithm as a python class, and is extremely flexible and applicable to a large suite of problems. pymc includes methods for summarizing output, plotting, goodness-of-fit and convergence diagnostics. 5 | 6 | pymc only requires NumPy. All other dependencies such as matplotlib, SciPy, pytables, or sqlite are optional. 7 | 8 | """ 9 | 10 | __version__ = '2.3.8' 11 | 12 | try: 13 | import numpy 14 | except ImportError as ie: 15 | print(ie, 16 | '\nNumPy does not seem to be installed. Please see the user guide.') 17 | 18 | # Core modules 19 | from .threadpool import * 20 | import os 21 | import pymc 22 | if os.getcwd().find( 23 | os.path.abspath(os.path.split(os.path.split(pymc.__file__)[0])[0])) > -1: 24 | from .six import print_ 25 | print_('\n\tWarning: You are importing PyMC from inside its source tree.') 26 | from .Node import * 27 | from .Container import * 28 | from .PyMCObjects import * 29 | from .InstantiationDecorators import * 30 | from .CommonDeterministics import * 31 | from .NumpyDeterministics import * 32 | from .distributions import * 33 | from .Model import * 34 | from .StepMethods import * 35 | from .MCMC import * 36 | from .NormalApproximation import * 37 | 38 | 39 | from .tests import test 40 | 41 | # Utilities modules 42 | from . import utils 43 | append = utils.append 44 | from . import CommonDeterministics 45 | from . import NumpyDeterministics 46 | from .CircularStochastic import * 47 | from . import distributions 48 | from . import gp 49 | 50 | # Optional modules 51 | try: 52 | from .diagnostics import * 53 | except ImportError: 54 | pass 55 | 56 | try: 57 | from . import ScipyDistributions 58 | except ImportError: 59 | pass 60 | 61 | try: 62 | import parallel 63 | except ImportError: 64 | pass 65 | 66 | try: 67 | from . import sandbox 68 | except ImportError: 69 | pass 70 | 71 | try: 72 | from . import graph 73 | except ImportError: 74 | pass 75 | 76 | try: 77 | from . import Matplot 78 | except: 79 | pass 80 | -------------------------------------------------------------------------------- /pymc/calc_utils.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Jan 20, 2011 3 | 4 | @author: jsalvatier 5 | ''' 6 | import numpy as np 7 | from collections import defaultdict 8 | 9 | _sts_memory = defaultdict(dict) 10 | 11 | 12 | def sum_to_shape(key1, key2, value, sum_shape): 13 | 14 | try: 15 | axes, lx = _sts_memory[key1][key2] 16 | 17 | except KeyError: 18 | 19 | value_shape = np.array(np.shape(value)) 20 | 21 | sum_shape_expanded = np.zeros(value_shape.size) 22 | sum_shape_expanded[0:len(sum_shape)] += np.array(sum_shape) 23 | 24 | axes = np.where(sum_shape_expanded != value_shape)[0] 25 | lx = np.size(axes) 26 | 27 | _sts_memory[key1][key2] = (axes, lx) 28 | 29 | if lx > 0: 30 | return np.apply_over_axes(np.sum, value, axes) 31 | 32 | else: 33 | return value 34 | -------------------------------------------------------------------------------- /pymc/database/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | ========================== 3 | Database backends for PyMC 4 | ========================== 5 | 6 | A typical MCMC run will generate thousands of samples, and some application 7 | requires well over 100000 iterations. Keeping all this information in memory 8 | can badly strain the performances of PyMC, and users will find their other 9 | applications slowing down. Moreover, we generally wish to store all or part 10 | of the sampled data for future use. To do so, PyMC offers different storing 11 | strategies: 12 | 13 | - `no_trace` : don't keep track of the samples, 14 | - `ram` : keep everything in RAM (default), 15 | - `pickle` : put traces in a dictionnary and pickle it once sampling is over. 16 | - `txt` : keep everything in RAM, and dump samples in txt files once 17 | sampling is completed, 18 | - `sqlite` : store data in a sqlite database, 19 | - `hdf5` : store data in a hdf5 file, using pytables. 20 | 21 | Although what happens under the hood is very different from one backend to 22 | another, from the user perspective, there is no difference whatsoever. The only 23 | thing that will change is the output file (if any) generated by the backend. 24 | 25 | Writing a new backend 26 | --------------------- 27 | 28 | Each backend is implemented in a file in the database directory. Each one 29 | of these files define two classes: Trace and Database. A new backend 30 | can easily be implemented by defining new classes and saving them in a 31 | file. Look at base.py for skeleton classes, and the other modules for examples. 32 | 33 | """ 34 | 35 | __modules__ = [ 36 | 'no_trace', 37 | 'txt', 38 | 'ram', 39 | 'pickle', 40 | 'sqlite', 41 | 'hdf5', 42 | 'hdf5ea', 43 | "__test_import__"] 44 | 45 | from . import no_trace 46 | from . import txt 47 | from . import ram 48 | from . import pickle 49 | 50 | try: 51 | from . import sqlite 52 | except ImportError: 53 | pass 54 | 55 | try: 56 | from . import hdf5 57 | except ImportError: 58 | pass 59 | 60 | try: 61 | from . import hdf5ea 62 | except ImportError: 63 | pass 64 | -------------------------------------------------------------------------------- /pymc/database/no_trace.py: -------------------------------------------------------------------------------- 1 | # 2 | # no_trace database backend 3 | # No memory whatsoever of the samples. 4 | # 5 | 6 | from numpy import zeros, shape 7 | from . import base 8 | import pymc 9 | 10 | __all__ = ['Trace', 'Database'] 11 | 12 | 13 | class Trace(base.Trace): 14 | 15 | """The no-trace backend provides a minimalistic backend where no 16 | trace of the values sampled is kept. This may be useful for testing 17 | purposes. 18 | """ 19 | 20 | 21 | class Database(base.Database): 22 | 23 | """The no-trace backend provides a minimalistic backend where no 24 | trace of the values sampled is kept. This may be useful for testing 25 | purposes. 26 | """ 27 | 28 | def __init__(self, dbname): 29 | """Get the Trace from the local scope.""" 30 | self.__Trace__ = Trace 31 | self.__name__ = 'notrace' 32 | self.dbname = dbname 33 | -------------------------------------------------------------------------------- /pymc/datatypes.py: -------------------------------------------------------------------------------- 1 | from numpy import obj2sctype, ndarray 2 | from numpy import bool_ 3 | from numpy import byte, short, intc, int_, longlong, intp 4 | from numpy import ubyte, ushort, uintc, uint, ulonglong, uintp 5 | from numpy import single, float_, longfloat 6 | from numpy import csingle, complex_, clongfloat 7 | 8 | # These are only used for membership tests, but things break if they are sets 9 | # rather than lists. TK, Jan 2012. 10 | integer_dtypes = [ 11 | int, 12 | uint, 13 | byte, 14 | short, 15 | intc, 16 | int_, 17 | longlong, 18 | intp, 19 | ubyte, 20 | ushort, 21 | uintc, 22 | uint, 23 | ulonglong, 24 | uintp] 25 | try: 26 | integer_dtypes.append(long) 27 | except NameError: 28 | pass # long is just int for Python 3 29 | float_dtypes = [float, single, float_, longfloat] 30 | complex_dtypes = [complex, csingle, complex_, clongfloat] 31 | bool_dtypes = [bool, bool_] 32 | 33 | 34 | def check_type(stochastic): 35 | """ 36 | type, shape = check_type(stochastic) 37 | 38 | Checks the type of a stochastic's value. Output value 'type' may be 39 | bool, int, float, or complex. Nonnative numpy dtypes are lumped into 40 | these categories. Output value 'shape' is () if the stochastic's value 41 | is scalar, or a nontrivial tuple otherwise. 42 | """ 43 | val = stochastic.value 44 | 45 | if val.__class__ in bool_dtypes: 46 | return bool, () 47 | elif val.__class__ in integer_dtypes: 48 | return int, () 49 | elif val.__class__ in float_dtypes: 50 | return float, () 51 | elif val.__class__ in complex_dtypes: 52 | return complex, () 53 | elif isinstance(val, ndarray): 54 | if obj2sctype(val) in bool_dtypes: 55 | return bool, val.shape 56 | elif obj2sctype(val) in integer_dtypes: 57 | return int, val.shape 58 | elif obj2sctype(val) in float_dtypes: 59 | return float, val.shape 60 | elif obj2sctype(val) in complex_dtypes: 61 | return complex, val.shape 62 | else: 63 | return 'object', val.shape 64 | else: 65 | return 'object', () 66 | 67 | continuous_types = [float, complex] 68 | 69 | 70 | def is_continuous(stochastic): 71 | dtype, shape = check_type(stochastic) 72 | if dtype in continuous_types: 73 | return True 74 | else: 75 | return False 76 | -------------------------------------------------------------------------------- /pymc/decorators.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------- 2 | # Decorators 3 | #------------------------------------------------------------- 4 | 5 | import numpy as np 6 | from numpy import inf, random, sqrt 7 | import string 8 | import inspect 9 | import types 10 | import copy 11 | from . import distributions 12 | from .Node import ZeroProbability 13 | 14 | 15 | def deterministic_to_NDarray(arg): 16 | if isinstance(arg, proposition5.Deterministic): 17 | return arg.value 18 | else: 19 | return arg 20 | 21 | 22 | def prop(func): 23 | """Function decorator for defining property attributes 24 | 25 | The decorated function is expected to return a dictionary 26 | containing one or more of the following pairs: 27 | fget - function for getting attribute value 28 | fset - function for setting attribute value 29 | fdel - function for deleting attribute 30 | This can be conveniently constructed by the locals() builtin 31 | function; see: 32 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183 33 | """ 34 | return property(doc=func.__doc__, **func()) 35 | -------------------------------------------------------------------------------- /pymc/examples/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Examples for PyMC. 3 | """ 4 | -------------------------------------------------------------------------------- /pymc/examples/disaster_model.py: -------------------------------------------------------------------------------- 1 | """ 2 | A model for the disasters data with a changepoint 3 | 4 | changepoint ~ U(0, 110) 5 | early_mean ~ Exp(1.) 6 | late_mean ~ Exp(1.) 7 | disasters[t] ~ Po(early_mean if t <= switchpoint, late_mean otherwise) 8 | 9 | """ 10 | 11 | from pymc import * 12 | from numpy import array, empty 13 | from numpy.random import randint 14 | 15 | __all__ = [ 16 | 'disasters_array', 17 | 'switchpoint', 18 | 'early_mean', 19 | 'late_mean', 20 | 'rate', 21 | 'disasters'] 22 | 23 | disasters_array = array([4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6, 24 | 3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5, 25 | 2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0, 26 | 1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1, 27 | 0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2, 28 | 3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4, 29 | 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1]) 30 | 31 | # Define data and stochastics 32 | 33 | switchpoint = DiscreteUniform( 34 | 'switchpoint', 35 | lower=0, 36 | upper=110, 37 | doc='Switchpoint[year]') 38 | early_mean = Exponential('early_mean', beta=1.) 39 | late_mean = Exponential('late_mean', beta=1.) 40 | 41 | 42 | @deterministic(plot=False) 43 | def rate(s=switchpoint, e=early_mean, l=late_mean): 44 | ''' Concatenate Poisson means ''' 45 | out = empty(len(disasters_array)) 46 | out[:s] = e 47 | out[s:] = l 48 | return out 49 | 50 | disasters = Poisson('disasters', mu=rate, value=disasters_array, observed=True) 51 | -------------------------------------------------------------------------------- /pymc/examples/disaster_model_linear.py: -------------------------------------------------------------------------------- 1 | """ 2 | A model for the disasters data with an linearly varying mean: 3 | 4 | rate_of_mean ~ N(0,1) 5 | amp_of_mean ~ Exp(3) 6 | disasters[t] ~ Po(intercept_of_mean + slope_of_mean * t) 7 | """ 8 | 9 | from pymc import * 10 | from numpy import * 11 | 12 | 13 | disasters_array = array([4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6, 14 | 3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5, 15 | 2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0, 16 | 1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1, 17 | 0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2, 18 | 3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4, 19 | 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1]) 20 | 21 | # Define data and stochastics 22 | 23 | 24 | @stochastic 25 | def params_of_mean(value=array([-.005, 1.]), tau=.1, rate=4.): 26 | """ 27 | Intercept and slope of rate stochastic of poisson distribution 28 | Rate stochastic must be positive for t in [0,T] 29 | 30 | p(intercept, slope|tau,rate) = 31 | N(slope|0,tau) Exp(intercept|rate) 1(intercept>0) 1(intercept + slope * T>0) 32 | """ 33 | 34 | def logp(value, tau, rate): 35 | if value[1] > 0 and value[1] + value[0] * 110 > 0: 36 | return normal_like(value[0], 0., tau) + \ 37 | exponential_like(value[1], rate) 38 | else: 39 | return -Inf 40 | 41 | def random(tau, rate): 42 | val = zeros(2) 43 | val[0] = rnormal(0., tau) 44 | val[1] = rexponential(rate) 45 | while val[1] < 0 or val[1] + val[0] * 110 <= 0: 46 | val[0] = rnormal(0., tau) 47 | val[1] = rexponential(rate) 48 | return val 49 | 50 | 51 | @observed 52 | def disasters(value=disasters_array, params_of_mean=params_of_mean): 53 | """Annual occurences of coal mining disasters.""" 54 | val = params_of_mean[1] + params_of_mean[0] * arange(111) 55 | return poisson_like(value, val) 56 | -------------------------------------------------------------------------------- /pymc/examples/disaster_model_missing.py: -------------------------------------------------------------------------------- 1 | """ 2 | A model for the disasters data with a changepoint, with missing data 3 | 4 | changepoint ~ U(0,110) 5 | early_mean ~ Exp(1.) 6 | late_mean ~ Exp(1.) 7 | disasters[t] ~ Po(early_mean if t <= switchpoint, late_mean otherwise) 8 | 9 | """ 10 | __all__ = ['switch', 'early_mean', 'late_mean', 'disasters'] 11 | 12 | from pymc import DiscreteUniform, Exponential, deterministic, Poisson, Uniform, Lambda, MCMC, observed, poisson_like 13 | from pymc.distributions import Impute 14 | from numpy.ma import masked_values 15 | import numpy as np 16 | 17 | # Missing values indicated by None placeholder values 18 | disasters_array = np.array([4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6, 19 | 3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5, 20 | 2, 2, 3, 4, 2, 1, 3, None, 2, 1, 1, 1, 1, 3, 0, 0, 21 | 1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1, 22 | 0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2, 23 | 3, 3, 1, None, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4, 24 | 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1]) 25 | 26 | 27 | # Switchpoint 28 | switch = DiscreteUniform('switch', lower=0, upper=110) 29 | # Early mean 30 | early_mean = Exponential('early_mean', beta=1) 31 | # Late mean 32 | late_mean = Exponential('late_mean', beta=1) 33 | 34 | 35 | @deterministic(plot=False) 36 | def rate(s=switch, e=early_mean, l=late_mean): 37 | """Allocate appropriate mean to time series""" 38 | out = np.empty(len(disasters_array)) 39 | # Early mean prior to switchpoint 40 | out[:s] = e 41 | # Late mean following switchpoint 42 | out[s:] = l 43 | return out 44 | 45 | 46 | # The inefficient way, using the Impute function: 47 | # D = Impute('D', Poisson, disasters_array, mu=r) 48 | # 49 | # The efficient way, using masked arrays: 50 | # Generate masked array. Where the mask is true, 51 | # the value is taken as missing. 52 | masked_values = masked_values(disasters_array, value=None) 53 | 54 | # Pass masked array to data stochastic, and it does the right thing 55 | disasters = Poisson('disasters', mu=rate, value=masked_values, observed=True) 56 | -------------------------------------------------------------------------------- /pymc/examples/disaster_model_null.py: -------------------------------------------------------------------------------- 1 | """ 2 | A model for the disasters data with no changepoint: 3 | 4 | global_rate ~ Exp(3.) 5 | disasters[t] ~ Po(global_rate) 6 | """ 7 | 8 | from pymc import * 9 | from numpy import array 10 | 11 | __all__ = ['global_rate', 'disasters', 'disasters_array'] 12 | disasters_array = array([4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6, 13 | 3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5, 14 | 2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0, 15 | 1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1, 16 | 0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2, 17 | 3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4, 18 | 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1]) 19 | 20 | # Define the data and stochastics 21 | global_rate = Exponential('global_rate', beta=1. / 3) 22 | 23 | 24 | @stochastic(observed=True, dtype=int) 25 | def disasters(value=disasters_array, rate=global_rate): 26 | """Annual occurences of coal mining disasters.""" 27 | return poisson_like(value, rate) 28 | -------------------------------------------------------------------------------- /pymc/examples/gelman_bioassay.py: -------------------------------------------------------------------------------- 1 | from pymc import * 2 | from numpy import ones, array 3 | 4 | # Samples for each dose level 5 | n = 5 * ones(4, dtype=int) 6 | # Log-dose 7 | dose = array([-.86, -.3, -.05, .73]) 8 | 9 | # Logit-linear model parameters 10 | alpha = Normal('alpha', 0, 0.01) 11 | beta = Normal('beta', 0, 0.01) 12 | 13 | # Calculate probabilities of death 14 | theta = Lambda('theta', lambda a=alpha, b=beta, d=dose: invlogit(a + b * d)) 15 | 16 | # Data likelihood 17 | deaths = Binomial( 18 | 'deaths', 19 | n=n, 20 | p=theta, 21 | value=array([0, 22 | 1, 23 | 3, 24 | 5], 25 | dtype=float), 26 | observed=True) 27 | 28 | # Calculate LD50 29 | LD50 = Lambda('LD50', lambda a=alpha, b=beta: -a / b) 30 | -------------------------------------------------------------------------------- /pymc/examples/gp/MCMC.py: -------------------------------------------------------------------------------- 1 | from . import PyMCmodel 2 | from pymc import * 3 | from pylab import * 4 | import matplotlib 5 | matplotlib.rcParams['axes.facecolor'] = 'w' 6 | 7 | x = linspace(-1, 1, 400) 8 | 9 | n_fmesh = 51 10 | fmesh_is_obsmesh = False 11 | 12 | GPSampler = MCMC(PyMCmodel.make_model(n_fmesh, fmesh_is_obsmesh)) 13 | 14 | GPSampler.assign_step_methods() 15 | sm = GPSampler.step_method_dict[GPSampler.sm.f_eval][0] 16 | 17 | GPSampler.isample(iter=5000, burn=2500, thin=100) 18 | 19 | # Uncomment this for a medium run. 20 | # GPSampler.isample(iter=500,burn=0,thin=10) 21 | 22 | # Uncomment this for a short run. 23 | # GPSampler.isample(iter=50,burn=0,thin=1) 24 | 25 | if __name__ == '__main__': 26 | 27 | N_samps = len(GPSampler.sm.f.trace()) 28 | fmesh = GPSampler.fmesh 29 | obs_locs = GPSampler.actual_obs_locs 30 | 31 | close('all') 32 | 33 | mid_traces = [] 34 | figure(figsize=(12, 6)) 35 | subplot(1, 2, 1) 36 | for i in range(0, N_samps): 37 | f = GPSampler.sm.f.trace()[i](x) 38 | plot(x, f, linewidth=2) 39 | mid_traces.append(f[len(f) / 2]) 40 | plot(obs_locs, GPSampler.d.value, 'k.', markersize=16) 41 | axis([x.min(), x.max(), -2., 4.]) 42 | xlabel('x') 43 | ylabel('f(x)') 44 | title('Some samples of f') 45 | 46 | subplot(1, 2, 2) 47 | 48 | plot(mid_traces, linewidth=4) 49 | xlabel('iteration') 50 | ylabel('f(0)') 51 | title('The trace of f at midpoint') 52 | 53 | # Plot posterior of C and tau 54 | figure() 55 | subplot(2, 2, 1) 56 | plot(GPSampler.nu.trace()) 57 | title("Degree of differentiability of f") 58 | 59 | subplot(2, 2, 2) 60 | plot(GPSampler.phi.trace()) 61 | title("Pointwise prior variance of f") 62 | 63 | subplot(2, 2, 3) 64 | plot(GPSampler.theta.trace()) 65 | title("X-axis scaling of f") 66 | 67 | subplot(2, 2, 4) 68 | plot(GPSampler.V.trace()) 69 | title('Observation variance') 70 | 71 | # Plot posterior of M 72 | figure() 73 | subplot(1, 3, 1) 74 | plot(GPSampler.a.trace()) 75 | title("Quadratic coefficient of M") 76 | 77 | subplot(1, 3, 2) 78 | plot(GPSampler.b.trace()) 79 | title("Linear coefficient of M") 80 | 81 | subplot(1, 3, 3) 82 | plot(GPSampler.c.trace()) 83 | title("Constant term of M") 84 | 85 | try: 86 | figure() 87 | plot(GPSampler.obs_locs.trace()) 88 | for al in GPSampler.actual_obs_locs: 89 | plot([0, N_samps], [al, al], 'k-.') 90 | title('Observation locations') 91 | except: 92 | pass 93 | 94 | # show() 95 | -------------------------------------------------------------------------------- /pymc/examples/gp/PyMCmodel.py: -------------------------------------------------------------------------------- 1 | import pymc as pm 2 | import pymc.gp as gp 3 | from pymc.gp.cov_funs import matern 4 | import numpy as np 5 | import matplotlib.pyplot as pl 6 | import copy 7 | from numpy.random import normal 8 | 9 | 10 | def make_model(n_fmesh=11, fmesh_is_obsmesh=False): 11 | x = np.arange(-1., 1., .1) 12 | 13 | # Prior parameters of C 14 | nu = pm.Uniform('nu', 1., 3, value=1.5) 15 | phi = pm.Lognormal('phi', mu=.4, tau=1, value=1) 16 | theta = pm.Lognormal('theta', mu=.5, tau=1, value=1) 17 | 18 | # The covariance dtrm C is valued as a Covariance object. 19 | @pm.deterministic 20 | def C(eval_fun=gp.matern.euclidean, 21 | diff_degree=nu, amp=phi, scale=theta): 22 | return gp.NearlyFullRankCovariance(eval_fun, diff_degree=diff_degree, amp=amp, scale=scale) 23 | 24 | # Prior parameters of M 25 | a = pm.Normal('a', mu=1., tau=1., value=1) 26 | b = pm.Normal('b', mu=.5, tau=1., value=0) 27 | c = pm.Normal('c', mu=2., tau=1., value=0) 28 | 29 | # The mean M is valued as a Mean object. 30 | def linfun(x, a, b, c): 31 | return a * x ** 2 + b * x + c 32 | 33 | @pm.deterministic 34 | def M(eval_fun=linfun, a=a, b=b, c=c): 35 | return gp.Mean(eval_fun, a=a, b=b, c=c) 36 | 37 | # The actual observation locations 38 | actual_obs_locs = np.linspace(-.8, .8, 4) 39 | 40 | if fmesh_is_obsmesh: 41 | o = actual_obs_locs 42 | fmesh = o 43 | else: 44 | # The unknown observation locations 45 | o = pm.Normal('o', actual_obs_locs, 1000., value=actual_obs_locs) 46 | fmesh = np.linspace(-1, 1, n_fmesh) 47 | 48 | # The GP submodel 49 | sm = gp.GPSubmodel('sm', M, C, fmesh) 50 | 51 | # Observation variance 52 | V = pm.Lognormal('V', mu=-1, tau=1, value=.0001) 53 | observed_values = pm.rnormal(actual_obs_locs ** 2, 10000) 54 | 55 | # The data d is just array-valued. It's normally distributed about 56 | # GP.f(obs_x). 57 | d = pm.Normal( 58 | 'd', 59 | mu=sm.f(o), 60 | tau=1. / V, 61 | value=observed_values, 62 | observed=True) 63 | 64 | return locals() 65 | -------------------------------------------------------------------------------- /pymc/examples/gp/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Gaussian processes examples. 3 | """ 4 | -------------------------------------------------------------------------------- /pymc/examples/gp/basiscov.py: -------------------------------------------------------------------------------- 1 | from pymc.gp.cov_funs import * 2 | from numpy import * 3 | from copy import copy 4 | from pymc.gp import * 5 | 6 | N = 25 7 | 8 | # Generate mean 9 | 10 | 11 | def quadfun(x, a, b, c): 12 | return (a * x ** 2 + b * x + c) 13 | 14 | M = Mean(eval_fun=quadfun, a=1., b=.5, c=2.) 15 | 16 | # Generate basis covariance 17 | coef_cov = ones(2 * N + 1, dtype=float) 18 | for i in xrange(1, len(coef_cov)): 19 | coef_cov[i] = 1. / int(((i + 1) / 2)) ** 2.5 20 | 21 | basis = fourier_basis([N]) 22 | 23 | C = SeparableBasisCovariance(basis, coef_cov, xmin=[-2.], xmax=[2.]) 24 | 25 | obs_x = array([-.5, .5]) 26 | V = array([.002, .002]) 27 | data = array([3.1, 2.9]) 28 | 29 | observe(M=M, 30 | C=C, 31 | obs_mesh=obs_x, 32 | obs_V=V, 33 | obs_vals=data) 34 | 35 | if __name__ == '__main__': 36 | from pylab import * 37 | 38 | close('all') 39 | x = arange(-1., 1., .01) 40 | 41 | figure() 42 | # Plot the covariance function 43 | subplot(1, 2, 1) 44 | 45 | contourf( 46 | x, 47 | x, 48 | C(x, 49 | x).view(ndarray), 50 | origin='lower', 51 | extent=(-1., 52 | 1., 53 | -1., 54 | 1.), 55 | cmap=cm.bone) 56 | 57 | xlabel('x') 58 | ylabel('y') 59 | title('C(x,y)') 60 | axis('tight') 61 | colorbar() 62 | 63 | # Plot a slice of the covariance function 64 | subplot(1, 2, 2) 65 | 66 | plot(x, C(x, 0.).view(ndarray).ravel(), 'k-') 67 | 68 | xlabel('x') 69 | ylabel('C(x,.5)') 70 | title('A slice of C') 71 | 72 | figure() 73 | plot_envelope(M, C, x) 74 | for i in range(3): 75 | f = Realization(M, C) 76 | plot(x, f(x)) 77 | title('Three realizations') 78 | 79 | plot(obs_x, data, 'k.', markersize=16) 80 | 81 | # show() 82 | -------------------------------------------------------------------------------- /pymc/examples/gp/cov.py: -------------------------------------------------------------------------------- 1 | from pymc.gp import * 2 | from pymc.gp.cov_funs import matern 3 | from numpy import * 4 | 5 | C = Covariance( 6 | eval_fun=matern.euclidean, 7 | diff_degree=1.4, 8 | amp=.4, 9 | scale=1.) 10 | # C = Covariance(eval_fun = matern.euclidean, diff_degree = 1.4, amp = .4, scale = 1., rank_limit=100) 11 | # C = FullRankCovariance(eval_fun = matern.euclidean, diff_degree = 1.4, amp = .4, scale = 1.) 12 | # C = NearlyFullRankCovariance(eval_fun = matern.euclidean, diff_degree = 13 | # 1.4, amp = .4, scale = 1.) 14 | 15 | # - Plot - #### 16 | if __name__ == '__main__': 17 | from pylab import * 18 | 19 | x = arange(-1., 1., .01) 20 | clf() 21 | 22 | # Plot the covariance function 23 | subplot(1, 2, 1) 24 | 25 | contourf( 26 | x, 27 | x, 28 | C(x, 29 | x).view(ndarray), 30 | origin='lower', 31 | extent=(-1., 32 | 1., 33 | -1., 34 | 1.), 35 | cmap=cm.bone) 36 | 37 | xlabel('x') 38 | ylabel('y') 39 | title('C(x,y)') 40 | axis('tight') 41 | colorbar() 42 | 43 | # Plot a slice of the covariance function 44 | subplot(1, 2, 2) 45 | 46 | plot(x, C(x, 0).view(ndarray).ravel(), 'k-') 47 | 48 | xlabel('x') 49 | ylabel('C(x,0)') 50 | title('A slice of C') 51 | 52 | # show() 53 | -------------------------------------------------------------------------------- /pymc/examples/gp/covparams.py: -------------------------------------------------------------------------------- 1 | from pymc.gp import * 2 | from pymc.gp.cov_funs import * 3 | from numpy import * 4 | 5 | # Covariance 6 | C = Covariance( 7 | eval_fun=matern.euclidean, 8 | diff_degree=1.4, 9 | amp=1., 10 | scale=1.) 11 | # C = Covariance(eval_fun = pow_exp.euclidean, pow=1., amp=1., scale=1.) 12 | # C = Covariance(eval_fun = quadratic.euclidean, phi=1., amp=1., scale=.2) 13 | # C = Covariance(eval_fun = gaussian.euclidean, amp=1., scale=1.) 14 | # C = Covariance(eval_fun = sphere.euclidean, amp=1., scale=.5) 15 | 16 | # Mean 17 | 18 | 19 | def zero_fun(x): 20 | return 0. * x 21 | M = Mean(zero_fun) 22 | 23 | # - Plot - #### 24 | if __name__ == '__main__': 25 | from pylab import * 26 | 27 | x = arange(-1., 1., .01) 28 | 29 | close('all') 30 | figure() 31 | 32 | # Plot the covariance function 33 | subplot(2, 2, 1) 34 | 35 | contourf( 36 | x, 37 | x, 38 | C(x, 39 | x).view(ndarray), 40 | origin='lower', 41 | extent=(-1., 42 | 1., 43 | -1., 44 | 1.), 45 | cmap=cm.bone) 46 | 47 | xlabel('x') 48 | ylabel('y') 49 | title('C(x,y)') 50 | axis('tight') 51 | colorbar() 52 | 53 | # Plot a slice of the covariance function 54 | subplot(2, 2, 2) 55 | 56 | plot(x, C(x, 0).view(ndarray).ravel(), 'k-') 57 | axis([-1, 1, 0, 1]) 58 | 59 | xlabel('x') 60 | ylabel('C(x,0)') 61 | title('A slice of C') 62 | 63 | subplot(2, 1, 2) 64 | 65 | # plot_envelope(M, C, mesh=x) 66 | for i in range(3): 67 | f = Realization(M, C) 68 | plot(x, f(x)) 69 | 70 | xlabel('x') 71 | ylabel('f(x)') 72 | title('Three realizations') 73 | axis([-1, 1, -2, 2]) 74 | 75 | # show() 76 | -------------------------------------------------------------------------------- /pymc/examples/gp/mean.py: -------------------------------------------------------------------------------- 1 | from pymc.gp import * 2 | 3 | # Generate mean 4 | 5 | 6 | def quadfun(x, a, b, c): 7 | return (a * x ** 2 + b * x + c) 8 | 9 | M = Mean(quadfun, a=1., b=.5, c=2.) 10 | 11 | # - Plot - #### 12 | if __name__ == '__main__': 13 | from pylab import * 14 | x = arange(-1., 1., .1) 15 | 16 | clf() 17 | plot(x, M(x), 'k-') 18 | xlabel('x') 19 | ylabel('M(x)') 20 | axis('tight') 21 | # show() 22 | -------------------------------------------------------------------------------- /pymc/examples/gp/mesh_choice.py: -------------------------------------------------------------------------------- 1 | from . import PyMCmodel 2 | import pymc as pm 3 | from pymc import six 4 | import numpy as np 5 | import matplotlib.pyplot as pl 6 | import matplotlib 7 | matplotlib.rcParams['axes.facecolor'] = 'w' 8 | import time 9 | 10 | n_iter = 10000 11 | 12 | rej = [] 13 | times = [] 14 | mesh_sizes = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512] 15 | for mesh_size in [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]: 16 | six.print_(mesh_size) 17 | m = PyMCmodel.make_model(mesh_size, False) 18 | if mesh_size == 0: 19 | sm = pm.gp.MeshlessGPMetropolis(m['sm'].f) 20 | else: 21 | sm = pm.gp.GPEvaluationMetropolis(m['sm'].f_eval, proposal_sd=.01) 22 | t1 = time.time() 23 | for i in xrange(n_iter): 24 | sm.step() 25 | times.append((time.time() - t1) / float(n_iter)) 26 | rej.append(sm.rejected / float(sm.rejected + sm.accepted)) 27 | 28 | m = PyMCmodel.make_model(0, True) 29 | sm = pm.gp.GPEvaluationMetropolis(m['sm'].f_eval, proposal_sd=.01) 30 | t1 = time.time() 31 | for i in xrange(n_iter): 32 | sm.step() 33 | truemesh_time = (time.time() - t1) / float(n_iter) 34 | truemesh_rej = sm.rejected / float(sm.rejected + sm.accepted) 35 | 36 | 37 | f = pl.figure(1, figsize=(12, 6)) 38 | ax1 = f.add_subplot(111) 39 | ax1.plot(rej, 'b-', label='Rejection', linewidth=4) 40 | ax1.plot([3], [truemesh_rej], 'b.', markersize=8) 41 | ax1.set_ylabel('Rejection rate', color='b') 42 | ax1.set_xticks(range(len(mesh_sizes))) 43 | ax1.set_xticklabels(mesh_sizes) 44 | ax1.set_xlabel('Number of points in mesh') 45 | 46 | 47 | ax2 = ax1.twinx() 48 | ax2.plot(times, 'r-', label='Time', linewidth=4) 49 | ax2.plot([3], [truemesh_time], 'r.', markersize=8) 50 | ax2.set_ylabel('Time per jump (seconds)', color='r') 51 | ax2.set_xticks(range(len(mesh_sizes))) 52 | ax2.set_xticklabels(mesh_sizes) 53 | ax2.set_xlabel('Number of points in mesh') 54 | -------------------------------------------------------------------------------- /pymc/examples/gp/more_examples/Duffy/africa.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/examples/gp/more_examples/Duffy/africa.hdf5 -------------------------------------------------------------------------------- /pymc/examples/gp/more_examples/Geostats/getdata.py: -------------------------------------------------------------------------------- 1 | from numpy import * 2 | 3 | # Whhether to thin dataset; definitely thin it if you're running this example on your laptop! 4 | thin = False 5 | 6 | l = open('walker_01.dat').read().splitlines()[8:-1] 7 | a = array([fromstring(line,sep='\t') for line in l]) 8 | if thin: 9 | a=a[::5] 10 | ident,x,y,v,u,t=a.T 11 | mesh = vstack((x,y)).T -------------------------------------------------------------------------------- /pymc/examples/gp/more_examples/Geostats/model.py: -------------------------------------------------------------------------------- 1 | from pymc import * 2 | from pymc.gp import * 3 | from pymc.gp.cov_funs import matern 4 | from getdata import * 5 | from pylab import * 6 | 7 | # ============ 8 | # = The mean = 9 | # ============ 10 | 11 | # Vague prior for the overall mean 12 | m = Uninformative('m', value=0) 13 | 14 | def constant(x, val): 15 | return zeros(x.shape[:-1],dtype=float) + val 16 | 17 | @deterministic 18 | def M(m=m): 19 | return Mean(constant, val=m) 20 | 21 | # ================== 22 | # = The covariance = 23 | # ================== 24 | 25 | # Informative prior for the degree of differentiability 26 | diff_degree = Uniform('diff_degree',.5,2,value=1) 27 | 28 | # Vague priors for the amplitude and scale 29 | amp = Exponential('amp',7.e-5, value=np.std(v)) 30 | scale = Exponential('scale',4e-3, value=x.max()/2) 31 | @deterministic 32 | def C(amp=amp, scale=scale, diff_degree=diff_degree): 33 | return FullRankCovariance(matern.euclidean, diff_degree = diff_degree, amp = amp, scale = scale) 34 | 35 | # =================== 36 | # = The GP submodel = 37 | # =================== 38 | walker_v = GPSubmodel('walker_v', M, C, mesh) 39 | 40 | # ============ 41 | # = The data = 42 | # ============ 43 | 44 | # Vague prior for the observation variance 45 | V = Exponential('V',5e-9, value=np.std(v)) 46 | 47 | # This is the observation of the elevation variable 'v', plus normally-distributed error. 48 | d = Normal('d',walker_v.f_eval,1./V,value=v,observed=True) 49 | 50 | 51 | -------------------------------------------------------------------------------- /pymc/examples/gp/more_examples/MKMsalmon/MCMC.py: -------------------------------------------------------------------------------- 1 | from salmon_sampler import * 2 | from pylab import * 3 | 4 | # salmon = SalmonSampler('chum') 5 | # salmon = SalmonSampler('sockeye') 6 | salmon = SalmonSampler('pink') 7 | 8 | 9 | # Really takes 100k 10 | iter=100000 11 | thin=iter/2000 12 | burn=50000 13 | # salmon.sample(iter=iter,burn=burn,thin=thin) 14 | salmon.isample(iter=iter,burn=burn,thin=thin) 15 | 16 | 17 | close('all') 18 | salmon.plot_SR() 19 | salmon.plot_traces() 20 | -------------------------------------------------------------------------------- /pymc/examples/gp/more_examples/MKMsalmon/chum.csv: -------------------------------------------------------------------------------- 1 | 487,0.98 2 | 92,0.23 3 | 202,0.47 4 | 1138,2.7 5 | 1236,3.23 6 | 482,1.24 7 | 696,1.76 8 | 7333,12.51 9 | 3077,4.29 10 | 2893,6.18 11 | 2532,6.24 12 | 6322,5.86 13 | 2486,1.65 14 | 3535,2.39 15 | 2753,3.06 16 | 1905,1.87 17 | 2928,2.81 18 | 3160,3.67 19 | 2927,4.43 20 | 2186,1.69 21 | 2812,1.98 22 | 333,0.23 23 | 509,0.77 24 | 404,0.58 25 | 1570,0.93 26 | 1426,1.97 27 | 263,0.36 28 | 681,1.39 29 | 1366,2.67 30 | 1297,2.74 31 | 1360,2.5 32 | 1315,1.85 33 | 1567,3.31 34 | 1919,2.68 35 | -------------------------------------------------------------------------------- /pymc/examples/gp/more_examples/MKMsalmon/pink.csv: -------------------------------------------------------------------------------- 1 | 32,0.04 2 | 70,0.11 3 | 108,0.19 4 | 178,0.24 5 | 364,0.54 6 | 633,0.39 7 | 600,0.28 8 | 444,0.11 9 | 671,0.26 10 | 1030,1.17 11 | 2297,0.92 12 | 660,0.81 13 | 1326,0.92 14 | 1156,1.48 15 | 1823,1.36 16 | 1077,0.85 17 | 1497,0.97 18 | 821,0.62 19 | -------------------------------------------------------------------------------- /pymc/examples/gp/more_examples/MKMsalmon/regression.py: -------------------------------------------------------------------------------- 1 | from salmon import * 2 | 3 | # Create a salmon instance for each datafile. 4 | chum = salmon('chum') 5 | sockeye = salmon('sockeye') 6 | pink = salmon('pink') 7 | 8 | # Fit and make plots. 9 | close('all') 10 | 11 | for species in [chum, sockeye, pink]: 12 | 13 | observe(species.M, 14 | species.C, 15 | obs_mesh = species.abundance, 16 | obs_vals = species.frye, 17 | obs_V = .25*species.frye) 18 | 19 | species.plot() 20 | 21 | path = "../../Docs/figs/MMK" + species.name + "reg.pdf" 22 | # savefig(path) 23 | 24 | # show() 25 | -------------------------------------------------------------------------------- /pymc/examples/gp/more_examples/MKMsalmon/salmon.py: -------------------------------------------------------------------------------- 1 | from pymc.gp import * 2 | from pymc.gp.cov_funs import matern 3 | from numpy import * 4 | from pylab import * 5 | from csv import * 6 | 7 | # Declare salmon class 8 | 9 | class salmon(object): 10 | """ 11 | Reads and organizes data from csv files, 12 | acts as a container for mean and covariance objects, 13 | makes plots. 14 | """ 15 | def __init__(self, name): 16 | 17 | # Read in data 18 | 19 | self.name = name 20 | f = file(name+'.csv') 21 | r = reader(f,dialect='excel') 22 | 23 | lines = [] 24 | for line in r: 25 | lines.append(line) 26 | f.close() 27 | 28 | data = zeros((len(lines), 2),dtype=float) 29 | for i in range(len(lines)): 30 | data[i,:] = array(lines[i]) 31 | 32 | self.abundance = data[:,0].ravel() 33 | self.frye = data[:,1].ravel() 34 | 35 | # Specify priors 36 | 37 | # Function for prior mean 38 | def line(x, slope): 39 | return slope * x 40 | 41 | self.M = Mean(line, slope = mean(self.frye / self.abundance)) 42 | 43 | self.C = Covariance( matern.euclidean, 44 | diff_degree = 1.4, 45 | scale = 100. * self.abundance.max(), 46 | amp = 200. * self.frye.max()) 47 | 48 | observe(self.M,self.C,obs_mesh = 0, obs_vals = 0, obs_V = 0) 49 | 50 | self.xplot = linspace(0,1.25 * self.abundance.max(),100) 51 | 52 | 53 | 54 | def plot(self): 55 | """ 56 | Plot posterior from simple nonstochetric regression. 57 | """ 58 | figure() 59 | plot_envelope(self.M, self.C, self.xplot) 60 | for i in range(3): 61 | f = Realization(self.M, self.C) 62 | plot(self.xplot,f(self.xplot)) 63 | 64 | plot(self.abundance, self.frye, 'k.', markersize=4) 65 | xlabel('Female abundance') 66 | ylabel('Frye density') 67 | title(self.name) 68 | axis('tight') 69 | -------------------------------------------------------------------------------- /pymc/examples/gp/more_examples/MKMsalmon/sockeye.csv: -------------------------------------------------------------------------------- 1 | 2986,9 2 | 3424,12.39 3 | 1631,4.5 4 | 784,2.56 5 | 9671,32.62 6 | 2519,8.19 7 | 1520,4.51 8 | 6418,15.21 9 | 10857,35.05 10 | 15044,36.85 11 | 10287,25.68 12 | 16525,52.75 13 | 19172,19.52 14 | 17527,40.98 15 | 11424,26.67 16 | 24043,52.6 17 | 10244,21.62 18 | 30983,56.05 19 | 12037,29.31 20 | 25098,45.4 21 | 11362,18.88 22 | 24375,19.14 23 | 18281,33.77 24 | 14192,20.44 25 | 7527,21.66 26 | 6061,18.22 27 | 15536,42.9 28 | 18080,46.09 29 | 17354,38.82 30 | 17301,42.22 31 | 11486,21.96 32 | 20120,45.05 33 | 10700,13.7 34 | 12867,27.71 35 | -------------------------------------------------------------------------------- /pymc/examples/gp/observation.py: -------------------------------------------------------------------------------- 1 | # Import the mean and covariance 2 | from .mean import M 3 | from .cov import C 4 | from pymc.gp import * 5 | from numpy import * 6 | 7 | # Impose observations on the GP 8 | o = array([-.5, .5]) 9 | V = array([.002, .002]) 10 | data = array([3.1, 2.9]) 11 | observe(M, C, obs_mesh=o, obs_V=V, obs_vals=data) 12 | 13 | # Generate realizations 14 | f_list = [Realization(M, C) for i in range(3)] 15 | 16 | x = arange(-1., 1., .01) 17 | 18 | # - Plot - #### 19 | if __name__ == '__main__': 20 | from pylab import * 21 | 22 | x = arange(-1., 1., .01) 23 | 24 | clf() 25 | 26 | plot_envelope(M, C, mesh=x) 27 | 28 | for f in f_list: 29 | plot(x, f(x)) 30 | 31 | xlabel('x') 32 | ylabel('f(x)') 33 | title('Three realizations of the observed GP') 34 | axis('tight') 35 | 36 | 37 | # show() 38 | -------------------------------------------------------------------------------- /pymc/examples/gp/realizations.py: -------------------------------------------------------------------------------- 1 | # Import the mean and covariance 2 | from .mean import M 3 | from .cov import C 4 | from pymc.gp import * 5 | 6 | # Generate realizations 7 | f_list = [Realization(M, C) for i in range(3)] 8 | 9 | # - Plot - #### 10 | if __name__ == '__main__': 11 | from pylab import * 12 | 13 | x = arange(-1., 1., .01) 14 | clf() 15 | 16 | plot_envelope(M, C, x) 17 | 18 | for f in f_list: 19 | plot(x, f(x)) 20 | 21 | xlabel('x') 22 | ylabel('f(x)') 23 | title('Three realizations of the GP') 24 | axis('tight') 25 | 26 | # show() 27 | -------------------------------------------------------------------------------- /pymc/examples/melanoma.py: -------------------------------------------------------------------------------- 1 | """ 2 | Exponential survival model for melanoma data, taken from 3 | Bayesian Data Analysis (Ibrahim et al 2000) Example 2.1 4 | 5 | # JAGS model 6 | model { 7 | for(i in 1:N) { 8 | z[i] ~ dinterval(t[i], t.cen[i]) 9 | t[i] ~ dweib(1,mu[i]) 10 | 11 | eta[i] <- beta0 + beta[1]*trt[i] 12 | mu[i] <- exp(eta[i]) 13 | 14 | } 15 | 16 | # Priors 17 | for(j in 1:p) { 18 | beta[j] ~ dnorm(0,.0001) 19 | } 20 | 21 | beta0 ~ dnorm(0,.0001) 22 | 23 | } 24 | """ 25 | 26 | from pymc import Normal, Lambda, observed 27 | from numpy import exp, log 28 | from .melanoma_data import * 29 | 30 | # Convert censoring indicators to indicators for failure event 31 | failure = (censored == 0).astype(int) 32 | 33 | # Intercept for survival rate 34 | beta0 = Normal('beta0', mu=0.0, tau=0.0001, value=0.0) 35 | # Treatment effect 36 | beta1 = Normal('beta1', mu=0.0, tau=0.0001, value=0.0) 37 | 38 | # Survival rates 39 | lam = Lambda('lam', lambda b0=beta0, b1=beta1, t=treat: exp(b0 + b1 * t)) 40 | 41 | 42 | @observed 43 | def survival(value=t, lam=lam, f=failure): 44 | """Exponential survival likelihood, accounting for censoring""" 45 | return sum(f * log(lam) - lam * value) 46 | 47 | if __name__ == '__main__': 48 | from pymc import MCMC, Matplot 49 | 50 | # Instantiate model 51 | M = MCMC([beta0, beta1, lam, survival]) 52 | # Sample 53 | M.sample(10000, 5000) 54 | # Plot traces 55 | Matplot.plot(M) 56 | -------------------------------------------------------------------------------- /pymc/examples/weibull_fit.py: -------------------------------------------------------------------------------- 1 | """ 2 | ==================================================== 3 | Fitting the parameters of a statistical distribution 4 | ==================================================== 5 | 6 | This simple example shows how to fit the parameters of a 7 | statistical distribution given 8 | - a series of experimental data, 9 | - priors for the parameters. 10 | 11 | The statistical distribution chosen here is the Weibull 12 | distribution, but the same can be done for any other 13 | distribution. 14 | """ 15 | 16 | from pymc import rweibull, Uniform, Weibull 17 | 18 | """ 19 | First, we will create a fake data set using some 20 | fixed parameters. In real life, of course, you 21 | already have the data ! 22 | """ 23 | alpha = 3 24 | beta = 5 25 | N = 100 26 | dataset = rweibull(alpha, beta, N) 27 | 28 | """ 29 | Now we create a pymc model that defines the likelihood 30 | of the data set and prior assumptions about the value 31 | of the parameters. 32 | """ 33 | a = Uniform('a', lower=0, upper=10, value=5, doc='Weibull alpha parameter') 34 | b = Uniform('b', lower=0, upper=10, value=5, doc='Weibull beta parameter') 35 | like = Weibull('like', alpha=a, beta=b, value=dataset, observed=True) 36 | 37 | if __name__ == '__main__': 38 | 39 | from pymc import MCMC, Matplot 40 | 41 | # Sample the parameters a and b and analyze the results 42 | M = MCMC([a, b, like]) 43 | M.sample(10000, 5000) 44 | Matplot.plot(M) 45 | -------------------------------------------------------------------------------- /pymc/examples/weibull_fit_gof.py: -------------------------------------------------------------------------------- 1 | """ 2 | ==================================================== 3 | Fitting the parameters of a statistical distribution 4 | ==================================================== 5 | 6 | This simple example shows how to fit the parameters of a 7 | statistical distribution given 8 | - a series of experimental data, 9 | - priors for the parameters. 10 | 11 | The statistical distribution chosen here is the Weibull 12 | distribution, but the same can be done for any other 13 | distribution. 14 | """ 15 | 16 | from pymc import rweibull, Uniform, Weibull 17 | 18 | """ 19 | First, we will create a fake data set using some 20 | fixed parameters. In real life, of course, you 21 | already have the data ! 22 | """ 23 | alpha = 3 24 | beta = 5 25 | N = 100 26 | dataset = rweibull(alpha, beta, N) 27 | 28 | """ 29 | Now we create a pymc model that defines the likelihood 30 | of the data set and prior assumptions about the value 31 | of the parameters. 32 | """ 33 | a = Uniform('a', lower=0, upper=10, value=5, doc='Weibull alpha parameter') 34 | b = Uniform('b', lower=0, upper=10, value=5, doc='Weibull beta parameter') 35 | like = Weibull('like', alpha=a, beta=b, value=dataset, observed=True) 36 | pred = Weibull('like', alpha=a, beta=b, value=dataset) 37 | 38 | if __name__ == '__main__': 39 | 40 | from pymc import MCMC, Matplot 41 | 42 | # Sample the parameters a and b and analyze the results 43 | M = MCMC([a, b, like]) 44 | M.sample(10000, 5000) 45 | Matplot.plot(M) 46 | -------------------------------------------------------------------------------- /pymc/examples/zip.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | zip.py 4 | 5 | Zero-inflated Poisson example using simulated data. 6 | """ 7 | import numpy as np 8 | from pymc import Uniform, Beta, observed, rpoisson, poisson_like 9 | 10 | # True parameter values 11 | mu_true = 5 12 | psi_true = 0.75 13 | n = 100 14 | 15 | # Simulate some data 16 | data = np.array([rpoisson(mu_true) * (np.random.random() < psi_true) 17 | for i in range(n)]) 18 | 19 | # Uniorm prior on Poisson mean 20 | mu = Uniform('mu', 0, 20) 21 | # Beta prior on psi 22 | psi = Beta('psi', alpha=1, beta=1) 23 | 24 | 25 | @observed(dtype=int, plot=False) 26 | def zip(value=data, mu=mu, psi=psi): 27 | """ Zero-inflated Poisson likelihood """ 28 | 29 | # Initialize likeihood 30 | like = 0.0 31 | 32 | # Loop over data 33 | for x in value: 34 | 35 | if not x: 36 | # Zero values 37 | like += np.log((1. - psi) + psi * np.exp(-mu)) 38 | 39 | else: 40 | # Non-zero values 41 | like += np.log(psi) + poisson_like(x, mu) 42 | 43 | return like 44 | 45 | if __name__ == "__main__": 46 | 47 | from pymc import MCMC, Matplot 48 | 49 | # Run model and plot posteriors 50 | M = MCMC(locals()) 51 | M.sample(100000, 50000) 52 | Matplot.plot(M) 53 | -------------------------------------------------------------------------------- /pymc/flib.so.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.flib.so 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/ESSBPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/ESSBPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/ESSDPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/ESSDPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/ESSVphiPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/ESSVphiPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/ESSVpsiPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/ESSVpsiPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/ESSblowfly.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | "TSdata" [shape=box]; 3 | "tau" [shape=box]; 4 | "meas_V" [shape=box]; 5 | "V_phi"; 6 | "RickerSlope"; 7 | "D"; 8 | "phi"; 9 | "B_amp"; 10 | "TS_IC"; 11 | "D_amp"; 12 | "B"; 13 | "mu_psi"; 14 | "V_psi"; 15 | "psi"; 16 | "RickerRate"; 17 | "mu_phi"; 18 | "MortalityMean"; 19 | "B_M" [shape=invtriangle]; 20 | "B_C" [shape=invtriangle]; 21 | "D_C" [shape=invtriangle]; 22 | "D_M" [shape=invtriangle]; 23 | "TS" [shape=invtriangle]; 24 | "RickerSlope" -> "B_M" [label=slope]; 25 | "RickerRate" -> "B_M" [label=rate]; 26 | "mu_psi" -> "psi" [label=mu]; 27 | "V_psi" -> "psi" [label=V]; 28 | "D_C" -> "D" [label=C]; 29 | "D_M" -> "D" [label=M]; 30 | "mu_phi" -> "phi" [label=mu]; 31 | "V_phi" -> "phi" [label=V]; 32 | "tau" -> "TS" [label=tau]; 33 | "phi" -> "TS" [label=phi]; 34 | "psi" -> "TS" [label=psi]; 35 | "D" -> "TS" [label=D]; 36 | "B" -> "TS" [label=B]; 37 | "TS_IC" -> "TS" [label=IC]; 38 | "B_amp" -> "B_C" [label=amp]; 39 | "D_amp" -> "D_C" [label=amp]; 40 | "MortalityMean" -> "D_M" [label=mean]; 41 | "TS" -> "TSdata" [label=mu]; 42 | "meas_V" -> "TSdata" [label=V]; 43 | "B_C" -> "B" [label=C]; 44 | "B_M" -> "B" [label=M]; 45 | } 46 | -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/ESSblowfly.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/ESSblowfly.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/ESSblowflyfit.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/ESSblowflyfit.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/ESSmuphiPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/ESSmuphiPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/ESSmupsiPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/ESSmupsiPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/MMKchumreg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/MMKchumreg.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/MMKpinkreg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/MMKpinkreg.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/MMKsalmon.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | "obs_frye" [shape=box]; 3 | "diff_degree"; 4 | "frye_tau"; 5 | "pink.SR"; 6 | "beta_0"; 7 | "beta_1"; 8 | "invtausq"; 9 | "scale"; 10 | "C" [shape=invtriangle]; 11 | "M" [shape=invtriangle]; 12 | "frye_V" [shape=invtriangle]; 13 | "amp" [shape=invtriangle]; 14 | "beta_1" -> "M" [label=beta_1]; 15 | "beta_0" -> "M" [label=beta_0]; 16 | "amp" -> "C" [label=amp]; 17 | "diff_degree" -> "C" [label=diff_degree]; 18 | "scale" -> "C" [label=scale]; 19 | "frye_tau" -> "frye_V" [label=frye_tau]; 20 | "C" -> "pink.SR" [label=C]; 21 | "M" -> "pink.SR" [label=M]; 22 | "pink.SR" -> "obs_frye" [label=SR]; 23 | "frye_tau" -> "obs_frye" [label=tau]; 24 | "invtausq" -> "amp" [label=invtausq]; 25 | } 26 | -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/MMKsalmon.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/MMKsalmon.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/MMKsockeyereg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/MMKsockeyereg.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/PyMC_cartoon.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/PyMC_cartoon.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/basiscov.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/basiscov.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/cond.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/cond.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/cov.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/cov.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d100a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d100a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d10a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d10a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d14a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d14a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d14a1s1close.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d14a1s1close.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d14a1s4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d14a1s4.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d14a1s4far.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d14a1s4far.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d14a4s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d14a4s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d20a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d20a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d2a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d2a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d4a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d4a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d5a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d5a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/d8a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/d8a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/densemeshpropose.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/densemeshpropose.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/elevdraw0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/elevdraw0.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/elevdraw1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/elevdraw1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/elevmean.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/elevmean.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/elevvar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/elevvar.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/gibbsSamples.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/gibbsSamples.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/lightmeshpropose.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/lightmeshpropose.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/mean.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/mean.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/metroSamples.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/metroSamples.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/nomeshpropose.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/nomeshpropose.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/obs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/obs.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/obscov.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/obscov.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/observed.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | "d" [shape=box]; 3 | "tau"; 4 | "M_b"; 5 | "M_a"; 6 | "C_amp"; 7 | "M_c"; 8 | "C_diff_degree"; 9 | "f"; 10 | "C_scale"; 11 | "C" [shape=invtriangle]; 12 | "M" [shape=invtriangle]; 13 | "M_a" -> "M" [label=a]; 14 | "C" -> "M" [label=C]; 15 | "M_b" -> "M" [label=b]; 16 | "M_c" -> "M" [label=c]; 17 | "d" -> "M" [label=obs_vals]; 18 | "C" -> "f" [label=C]; 19 | "M" -> "f" [label=M]; 20 | "tau" -> "C" [label=obs_tau]; 21 | "C_diff_degree" -> "C" [label=diff_degree]; 22 | "C_scale" -> "C" [label=scale]; 23 | "C_amp" -> "C" [label=amp]; 24 | } 25 | -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/observedModel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/observedModel.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/pinkVpost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/pinkVpost.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/pinkamppost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/pinkamppost.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/pinkampscale.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/pinkampscale.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/pinkbeta0post.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/pinkbeta0post.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/pinkbeta1post.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/pinkbeta1post.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/pinkdiffdegreepost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/pinkdiffdegreepost.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/pinkfpost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/pinkfpost.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/pinkscalepost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/pinkscalepost.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/prismdraw0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/prismdraw0.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/prismdraw1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/prismdraw1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/prismdraw2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/prismdraw2.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/prismmean.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/prismmean.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/prismvar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/prismvar.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/realizations.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/realizations.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/sampmethod_cartoon.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/sampmethod_cartoon.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/unobserved.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | "d" [shape=box]; 3 | "M_b"; 4 | "tau"; 5 | "C_scale"; 6 | "f"; 7 | "C_amp"; 8 | "M_c"; 9 | "M_a"; 10 | "C_diff_degree"; 11 | "C" [shape=invtriangle]; 12 | "M" [shape=invtriangle]; 13 | "f" -> "d" [label=mu]; 14 | "tau" -> "d" [label=tau]; 15 | "C" -> "f" [label=C]; 16 | "M" -> "f" [label=M]; 17 | "C_amp" -> "C" [label=amp]; 18 | "C_diff_degree" -> "C" [label=diff_degree]; 19 | "C_scale" -> "C" [label=scale]; 20 | "M_a" -> "M" [label=a]; 21 | "M_c" -> "M" [label=c]; 22 | "M_b" -> "M" [label=b]; 23 | } 24 | -------------------------------------------------------------------------------- /pymc/gp/Docs/algorithm/figs/unobservedModel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/algorithm/figs/unobservedModel.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/banner.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/banner.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/coverletter.tex: -------------------------------------------------------------------------------- 1 | \documentclass{letter} 2 | 3 | % \usepackage{garamond} 4 | \usepackage[colorlinks]{hyperref} 5 | % \usepackage[T1]{fontenc} 6 | 7 | \signature{Anand Patil} 8 | \address{Malaria Atlas Project\\ 9 | Department of Zoology\\ 10 | University of Oxford\\ 11 | Oxford, OX1 3PS, UK} 12 | 13 | \begin{document} 14 | % \garamond 15 | 16 | \begin{letter}{Jan de Leeuw and Achim Zeileis \\ Editors \\ Journal of Statistical Software} 17 | \opening{Dear Mr de Leeuw and Mr. Zeileis,} 18 | 19 | I am pleased to submit a paper presenting a Gaussian process package for the Bayesian analysis package PyMC. PyMC's user guide is due to be published shortly in JSS as `PyMC 2: Bayesian stochastic modeling in Python' by Patil, Huard and Fonnesbeck. 20 | 21 | I wrote the Gaussian process package in order to showcase the advantages of PyMC, and Python more broadly, for Bayesian analysis. It aims to provide a uniquely convenient and intuitive interface by using an object model that closely resembles the underlying mathematical concepts, while still allowing nearly unlimited flexibility in model construction and achieving good performance. I have used the package to conduct about a dozen geostatistical analyses in my work at the Malaria Atlas Project. 22 | 23 | The Gaussian process package is distributed with PyMC, but I have maintained it semi-independently and it is not covered by PyMC's documentation. I am confident that you will agree it represents a substantial contribution over and above PyMC itself, and deserves publication on its own. 24 | 25 | This paper is a condensed version of the package documentation, which is available from \href{http://pymc.googlecode.com/files/GPUserGuide.pdf}{PyMC's homepage on Google Code}. 26 | 27 | \closing{Sincerely,} 28 | 29 | \end{letter} 30 | 31 | \end{document} 32 | 33 | % \documentclass{letter} 34 | % \name{Anand Patil} 35 | % \signature{Anand Patil} 36 | % 37 | % \begin{document} 38 | % \begin{letter} 39 | % \opening{Dear Mr. de Leeuw,} 40 | % blah 41 | % \closing{Sincerely,} 42 | % \end{letter} 43 | % \end{document} 44 | -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/ESSBPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/ESSBPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/ESSDPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/ESSDPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/ESSVphiPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/ESSVphiPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/ESSVpsiPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/ESSVpsiPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/ESSblowfly.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | "TSdata" [shape=box]; 3 | "tau" [shape=box]; 4 | "meas_V" [shape=box]; 5 | "V_phi"; 6 | "RickerSlope"; 7 | "D"; 8 | "phi"; 9 | "B_amp"; 10 | "TS_IC"; 11 | "D_amp"; 12 | "B"; 13 | "mu_psi"; 14 | "V_psi"; 15 | "psi"; 16 | "RickerRate"; 17 | "mu_phi"; 18 | "MortalityMean"; 19 | "B_M" [shape=invtriangle]; 20 | "B_C" [shape=invtriangle]; 21 | "D_C" [shape=invtriangle]; 22 | "D_M" [shape=invtriangle]; 23 | "TS" [shape=invtriangle]; 24 | "RickerSlope" -> "B_M" [label=slope]; 25 | "RickerRate" -> "B_M" [label=rate]; 26 | "mu_psi" -> "psi" [label=mu]; 27 | "V_psi" -> "psi" [label=V]; 28 | "D_C" -> "D" [label=C]; 29 | "D_M" -> "D" [label=M]; 30 | "mu_phi" -> "phi" [label=mu]; 31 | "V_phi" -> "phi" [label=V]; 32 | "tau" -> "TS" [label=tau]; 33 | "phi" -> "TS" [label=phi]; 34 | "psi" -> "TS" [label=psi]; 35 | "D" -> "TS" [label=D]; 36 | "B" -> "TS" [label=B]; 37 | "TS_IC" -> "TS" [label=IC]; 38 | "B_amp" -> "B_C" [label=amp]; 39 | "D_amp" -> "D_C" [label=amp]; 40 | "MortalityMean" -> "D_M" [label=mean]; 41 | "TS" -> "TSdata" [label=mu]; 42 | "meas_V" -> "TSdata" [label=V]; 43 | "B_C" -> "B" [label=C]; 44 | "B_M" -> "B" [label=M]; 45 | } 46 | -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/ESSblowfly.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/ESSblowfly.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/ESSblowflyfit.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/ESSblowflyfit.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/ESSmuphiPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/ESSmuphiPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/ESSmupsiPosterior.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/ESSmupsiPosterior.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/MKMsalmon.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | "obs_frye" [style=filled]; 3 | "diff_degree"; 4 | "beta_1"; 5 | "frye_tau"; 6 | "scale"; 7 | "beta_0"; 8 | "pink.SR"; 9 | "invtausq"; 10 | "C" [shape=invtriangle]; 11 | "M" [shape=invtriangle]; 12 | "frye_V" [shape=invtriangle]; 13 | "amp" [shape=invtriangle]; 14 | "beta_1" -> "M" [label=beta_1]; 15 | "beta_0" -> "M" [label=beta_0]; 16 | "frye_tau" -> "frye_V" [label=frye_tau]; 17 | "invtausq" -> "amp" [label=invtausq]; 18 | "pink.SR" -> "obs_frye" [label=SR]; 19 | "frye_tau" -> "obs_frye" [label=tau]; 20 | "amp" -> "C" [label=amp]; 21 | "diff_degree" -> "C" [label=diff_degree]; 22 | "scale" -> "C" [label=scale]; 23 | "C" -> "pink.SR" [label=C]; 24 | "M" -> "pink.SR" [label=M]; 25 | } 26 | -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/MKMsalmon.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/MKMsalmon.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/MMKchumreg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/MMKchumreg.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/MMKpinkreg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/MMKpinkreg.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/MMKsockeyereg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/MMKsockeyereg.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/basiscov.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/basiscov.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/cond.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/cond.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/cov.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/cov.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d100a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d100a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d10a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d10a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d14a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d14a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d14a1s1close.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d14a1s1close.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d14a1s4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d14a1s4.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d14a1s4far.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d14a1s4far.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d14a4s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d14a4s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d20a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d20a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d2a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d2a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d4a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d4a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d5a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d5a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/d8a1s1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/d8a1s1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/densemeshpropose.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/densemeshpropose.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/elevdraw0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/elevdraw0.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/elevdraw1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/elevdraw1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/elevmean.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/elevmean.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/elevvar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/elevvar.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/gibbsSamples.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/gibbsSamples.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/lightmeshpropose.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/lightmeshpropose.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/mean.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/mean.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/metroSamples.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/metroSamples.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/nomeshpropose.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/nomeshpropose.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/obs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/obs.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/obscov.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/obscov.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/observed.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | "d" [shape=box]; 3 | "tau"; 4 | "M_b"; 5 | "M_a"; 6 | "C_amp"; 7 | "M_c"; 8 | "C_diff_degree"; 9 | "f"; 10 | "C_scale"; 11 | "C" [shape=invtriangle]; 12 | "M" [shape=invtriangle]; 13 | "M_a" -> "M" [label=a]; 14 | "C" -> "M" [label=C]; 15 | "M_b" -> "M" [label=b]; 16 | "M_c" -> "M" [label=c]; 17 | "d" -> "M" [label=obs_vals]; 18 | "C" -> "f" [label=C]; 19 | "M" -> "f" [label=M]; 20 | "tau" -> "C" [label=obs_tau]; 21 | "C_diff_degree" -> "C" [label=diff_degree]; 22 | "C_scale" -> "C" [label=scale]; 23 | "C_amp" -> "C" [label=amp]; 24 | } 25 | -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/observedModel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/observedModel.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/pinkVpost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/pinkVpost.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/pinkamppost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/pinkamppost.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/pinkampscale.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/pinkampscale.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/pinkbeta0post.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/pinkbeta0post.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/pinkbeta1post.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/pinkbeta1post.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/pinkdiffdegreepost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/pinkdiffdegreepost.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/pinkfpost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/pinkfpost.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/pinkscalepost.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/pinkscalepost.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/prismdraw0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/prismdraw0.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/prismdraw1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/prismdraw1.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/prismdraw2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/prismdraw2.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/prismmean.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/prismmean.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/prismvar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/prismvar.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/realizations.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/realizations.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/unobserved.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | "d" [shape=box]; 3 | "M_b"; 4 | "tau"; 5 | "C_scale"; 6 | "f"; 7 | "C_amp"; 8 | "M_c"; 9 | "M_a"; 10 | "C_diff_degree"; 11 | "C" [shape=invtriangle]; 12 | "M" [shape=invtriangle]; 13 | "f" -> "d" [label=mu]; 14 | "tau" -> "d" [label=tau]; 15 | "C" -> "f" [label=C]; 16 | "M" -> "f" [label=M]; 17 | "C_amp" -> "C" [label=amp]; 18 | "C_diff_degree" -> "C" [label=diff_degree]; 19 | "C_scale" -> "C" [label=scale]; 20 | "M_a" -> "M" [label=a]; 21 | "M_c" -> "M" [label=c]; 22 | "M_b" -> "M" [label=b]; 23 | } 24 | -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/unobservedModel.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | "d" [style=filled]; 3 | "c"; 4 | "diff_degree"; 5 | "b"; 6 | "amp"; 7 | "a"; 8 | "scale"; 9 | "f"; 10 | "V"; 11 | "M" [shape=invtriangle]; 12 | "C" [shape=invtriangle]; 13 | "C" -> "f" [label=C]; 14 | "M" -> "f" [label=M]; 15 | "a" -> "M" [label=a]; 16 | "c" -> "M" [label=c]; 17 | "b" -> "M" [label=b]; 18 | "f" -> "d" [label=mu]; 19 | "V" -> "d" [label=V]; 20 | "amp" -> "C" [label=amp]; 21 | "diff_degree" -> "C" [label=diff_degree]; 22 | "scale" -> "C" [label=scale]; 23 | } 24 | -------------------------------------------------------------------------------- /pymc/gp/Docs/figs/unobservedModel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/figs/unobservedModel.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/jss-gp.aux: -------------------------------------------------------------------------------- 1 | \relax 2 | -------------------------------------------------------------------------------- /pymc/gp/Docs/jss-gp.fdb_latexmk: -------------------------------------------------------------------------------- 1 | # Fdb version 3 2 | ["pdflatex"] 1516051073 "/Users/fonnescj/Repos/pymc/pymc/gp/Docs/jss-gp.tex" "jss-gp.pdf" "jss-gp" 1516051073 3 | "/Users/fonnescj/Repos/pymc/pymc/gp/Docs/jss-gp.tex" 1516051073 72086 ec88915e9e974e8b6fed6109c9d32267 "" 4 | "/usr/local/texlive/2016/texmf-dist/web2c/texmf.cnf" 1463093894 31953 b9489e6e586f798610c60aec1f5ec548 "" 5 | "/usr/local/texlive/2016/texmf-var/web2c/pdftex/pdflatex.fmt" 1463979169 3873397 413fbfbbedb8e719ddc392043a7add02 "" 6 | "/usr/local/texlive/2016/texmf.cnf" 1463979140 577 2938757e76f31531e65cc647e3507693 "" 7 | "jss-gp.aux" 1516051073 8 a94a2480d3289e625eea47cd1b285758 "" 8 | "jss-gp.tex" 1516051073 72086 ec88915e9e974e8b6fed6109c9d32267 "" 9 | "jss.cls" 0 -1 0 "" 10 | (generated) 11 | "jss-gp.pdf" 12 | "jss-gp.log" 13 | -------------------------------------------------------------------------------- /pymc/gp/Docs/jss-gp.fls: -------------------------------------------------------------------------------- 1 | PWD /Users/fonnescj/Repos/pymc/pymc/gp/Docs 2 | INPUT /usr/local/texlive/2016/texmf.cnf 3 | INPUT /usr/local/texlive/2016/texmf-dist/web2c/texmf.cnf 4 | INPUT /usr/local/texlive/2016/texmf-var/web2c/pdftex/pdflatex.fmt 5 | INPUT /Users/fonnescj/Repos/pymc/pymc/gp/Docs/jss-gp.tex 6 | OUTPUT jss-gp.log 7 | -------------------------------------------------------------------------------- /pymc/gp/Docs/jss-gp.log: -------------------------------------------------------------------------------- 1 | This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2016.5.22) 15 JAN 2018 15:17 2 | entering extended mode 3 | restricted \write18 enabled. 4 | file:line:error style messages enabled. 5 | %&-line parsing enabled. 6 | **/Users/fonnescj/Repos/pymc/pymc/gp/Docs/jss-gp.tex 7 | (/Users/fonnescj/Repos/pymc/pymc/gp/Docs/jss-gp.tex 8 | LaTeX2e <2016/03/31> 9 | Babel <3.9r> and hyphenation patterns for 83 language(s) loaded. 10 | 11 | ! LaTeX Error: File `jss.cls' not found. 12 | 13 | Type X to quit or to proceed, 14 | or enter new name. (Default extension: cls) 15 | 16 | Enter file name: 17 | /Users/fonnescj/Repos/pymc/pymc/gp/Docs/jss-gp.tex:10: Emergency stop. 18 | 19 | 20 | l.10 ^^M 21 | 22 | *** (cannot \read from terminal in nonstop modes) 23 | 24 | 25 | Here is how much of TeX's memory you used: 26 | 11 strings out of 493014 27 | 282 string characters out of 6133351 28 | 53601 words of memory out of 5000000 29 | 3651 multiletter control sequences out of 15000+600000 30 | 3640 words of font info for 14 fonts, out of 8000000 for 9000 31 | 1141 hyphenation exceptions out of 8191 32 | 10i,0n,7p,98b,8s stack positions out of 5000i,500n,10000p,200000b,80000s 33 | /Users/fonnescj/Repos/pymc/pymc/gp/Docs/jss-gp.tex:10: ==> Fatal error occurre 34 | d, no output PDF file produced! 35 | -------------------------------------------------------------------------------- /pymc/gp/Docs/logo_purple.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pymc-devs/pymc2/6b1b51ddea1a74c50d9a027741252b30810b29e0/pymc/gp/Docs/logo_purple.pdf -------------------------------------------------------------------------------- /pymc/gp/Docs/ltxmarkup.sty: -------------------------------------------------------------------------------- 1 | % Created by Fred L. Drake, Jr. , as part of the 2 | % Python Documentation Project. 3 | % 4 | % Define some simple markup for the LaTeX command documentation: 5 | 6 | \ProvidesPackage{ltxmarkup} 7 | \RequirePackage{python} % fulllineitems environment 8 | 9 | % These two macros are used in constructing the last parameter to the 10 | % envdesc and macrodesc environments. 11 | 12 | \newcommand{\py@ltx@optparam}[1]{{[}\var{#1}{]}} 13 | \newcommand{\py@ltx@param}[1]{\{\var{#1}\}} 14 | 15 | \newenvironment{envdesc}[2]{ 16 | \begin{fulllineitems} 17 | \item[\code{\e begin\{{\bfseries #1}\}{% 18 | \let\op=\py@ltx@optparam% 19 | \let\p=\py@ltx@param% 20 | \let\unspecified=\py@unspecified% 21 | \let\moreargs=\py@moreargs% 22 | #2}}] 23 | \item[\code{\e end\{{\bfseries #1}\}}] 24 | \index{#1 environment@\py@idxcode{#1} environment} 25 | \index{environments!#1@\py@idxcode{#1}} 26 | }{\end{fulllineitems}} 27 | 28 | \newenvironment{macrodesc}[2]{ 29 | \begin{fulllineitems} 30 | \item[\code{{\e\bfseries#1}{% 31 | \let\op=\py@ltx@optparam% 32 | \let\p=\py@ltx@param% 33 | \let\unspecified=\py@unspecified% 34 | \let\moreargs=\py@moreargs% 35 | #2}}] 36 | \index{#1@\py@idxcode{#1}} 37 | }{\end{fulllineitems}} 38 | 39 | \newcommand{\env}[1]{\code{#1}} 40 | \newcommand{\macro}[1]{\code{\e#1}} 41 | -------------------------------------------------------------------------------- /pymc/gp/Docs/pypaper.sty: -------------------------------------------------------------------------------- 1 | % 2 | % Change this to say a4paper instead of letterpaper if you want A4. These 3 | % are the latex defaults. 4 | % 5 | \newcommand{\py@paper}{letterpaper} 6 | \newcommand{\py@ptsize}{10pt} 7 | 8 | % These set up the fonts for the documents. 9 | % 10 | % The "times" package makes the default font the PostScript Times 11 | % font, which makes for smaller PostScript and a font that more people 12 | % like. 13 | % 14 | % The "avant" package causes the AvantGarde font to be used for 15 | % sans-serif text, instead of the uglier Helvetica set up by the "times" 16 | % package. 17 | % 18 | \RequirePackage{times}\typeout{Using Times instead of Computer Modern.} 19 | -------------------------------------------------------------------------------- /pymc/gp/Docs/python.ist: -------------------------------------------------------------------------------- 1 | line_max 100 2 | headings_flag 1 3 | heading_prefix " \\bigletter " 4 | 5 | preamble "\\begin{theindex} 6 | \\def\\bigletter#1{{\\Large\\sffamily#1}\\nopagebreak\\vspace{1mm}} 7 | 8 | " 9 | 10 | symhead_positive "{Symbols}" 11 | numhead_positive "{Numbers}" 12 | -------------------------------------------------------------------------------- /pymc/gp/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Anand Patil, 2007 2 | 3 | # Where matrix evaluations can be done in chunks, the chunk size will be 4 | # kept below this limit. 5 | chunksize = 1e8 6 | 7 | __modules__ = ['GPutils', 8 | 'Mean', 9 | 'Covariance', 10 | 'BasisCovariance', 11 | 'FullRankCovariance', 12 | 'NearlyFullRankCovariance', 13 | 'Realization', 14 | 'cov_funs', 15 | 'gp_submodel', 16 | 'step_methods'] 17 | 18 | __optmodules__ = ['gpplots'] 19 | 20 | from .GPutils import * 21 | from .Mean import * 22 | from .Covariance import * 23 | from .BasisCovariance import * 24 | from .FullRankCovariance import * 25 | from .NearlyFullRankCovariance import * 26 | from .Realization import * 27 | from .cov_funs import * 28 | from .gp_submodel import * 29 | from .step_methods import * 30 | 31 | try: 32 | from . import gpplots 33 | except ImportError: 34 | pass 35 | 36 | try: 37 | import SparseCovariance 38 | except ImportError: 39 | pass 40 | -------------------------------------------------------------------------------- /pymc/gp/cov_funs/__init__.py: -------------------------------------------------------------------------------- 1 | from .isotropic_cov_funs import * 2 | from .cov_utils import * 3 | from .bases import * 4 | from .wrapped_distances import * 5 | from . import isotropic_cov_funs 6 | from .brownian import * 7 | from .nsmatern import * 8 | 9 | 10 | 11 | extra_parameters = {'gaussian': {'': ''}, 12 | 'pow_exp': {'pow': 'The exponent in the exponential.'}, 13 | 'exponential':{'':''}, 14 | 'matern': {'diff_degree': 'The degree of differentiability of realizations.'}, 15 | 'sphere': {'': ''}, 16 | 'quadratic': {'phi': 'The characteristic (scaled) distance of decorrelation.'}, 17 | 'exponential': {'': ''}} 18 | 19 | 20 | for name in extra_parameters: 21 | locals()[name] = covariance_function_bundle(name, 'isotropic_cov_funs', extra_parameters[name], ampsq_is_diag=True) 22 | 23 | nsmatern_extra_params = {'diff_degree': 'A function giving the local degree of differentiability.', 24 | 'h': 'A function giving the local relative amplitude.'} 25 | nsmatern = covariance_function_bundle('nsmatern', 'nsmatern', 26 | nsmatern_extra_params, ampsq_is_diag=False, with_x=True) 27 | for w in nsmatern.wrappers: 28 | w.diag_call = nsmatern_diag 29 | 30 | -------------------------------------------------------------------------------- /pymc/gp/cov_funs/bases.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Anand Patil, 2007 2 | 3 | from numpy import * 4 | 5 | from pymc import six 6 | xrange = six.moves.xrange 7 | 8 | __all__ = ['fourier_basis'] 9 | 10 | def fourier_basis(n): 11 | 12 | n_dim = len(n) 13 | basis = [] 14 | 15 | for i in xrange(n_dim): 16 | 17 | def fun(x, xmin, xmax): 18 | return ones(x.shape[0], dtype=float) 19 | 20 | basis_now = [fun] 21 | 22 | for j in xrange(1,n[i]+1): 23 | 24 | def fun(x, xmin, xmax, j=j, i=i): 25 | T = xmax[i] - xmin[i] 26 | return cos(2.*j*pi*(x[:,i] - xmin[i]) / T) 27 | basis_now.append(fun) 28 | 29 | def fun(x, xmin, xmax, j=j, i=i): 30 | T = xmax[i] - xmin[i] 31 | return sin(2.*j*pi*(x[:,i] - xmin[i]) / T) 32 | basis_now.append(fun) 33 | 34 | basis.append(basis_now) 35 | 36 | return basis 37 | -------------------------------------------------------------------------------- /pymc/gp/cov_funs/distances.so.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.distances.so 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /pymc/gp/cov_funs/isotropic_cov_funs.so.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.isotropic_cov_funs.so 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /pymc/gp/cov_funs/nsmatern.py: -------------------------------------------------------------------------------- 1 | from . import isotropic_cov_funs 2 | import numpy as np 3 | 4 | 5 | __all__ = ['nsmatern','nsmatern_diag','default_h'] 6 | 7 | 8 | def default_h(x): 9 | return np.ones(x.shape[:-1]) 10 | 11 | def nsmatern(C,x,y,diff_degree,amp=1.,scale=1.,h=default_h,cmin=0,cmax=-1,symm=False): 12 | """ 13 | 14 | A covariance function. Remember, broadcasting for covariance functions works 15 | differently than for numpy universal functions. C(x,y) returns a matrix, and 16 | C(x) returns a vector. 17 | 18 | :Parameters: 19 | 20 | - `amp`: The pointwise standard deviation of f. 21 | 22 | - `scale`: The factor by which to scale the distance between points. 23 | Large value implies long-range correlation. 24 | 25 | - `diff_degree`: A function that takes arrays and returns the degree 26 | of differentiability at each location. 27 | 28 | - `h`: A function that takes arrays and returns the relative amplitude 29 | at each location. 30 | 31 | - `x and y` are arrays of points in Euclidean coordinates 32 | formatted as follows: 33 | 34 | [[x_{0,0} ... x_{0,ndim}], 35 | [x_{1,0} ... x_{1,ndim}], 36 | ... 37 | [x_{N,0} ... x_{N,ndim}]] 38 | 39 | - `symm` indicates whether x and y are references to 40 | the same array. 41 | 42 | - `cmin' and `cmax' indicate which columns to compute. 43 | These are used for multithreaded evaluation. 44 | 45 | :Reference: Pintore and Holmes, 2010, "Spatially adaptive non-stationary covariance functions 46 | via spatially adaptive spectra". Journal of the American Statistical Association. 47 | Forthcoming. 48 | """ 49 | ddx, ddy = diff_degree(x), diff_degree(y) 50 | hx, hy = h(x), h(y) 51 | 52 | # for rkbesl 53 | nmax = np.floor(max(np.max(ddx), np.max(ddy))) 54 | 55 | # Compute covariance for this bit 56 | isotropic_cov_funs.nsmatrn(C,ddx,ddy,hx,hy,nmax,cmin,cmax,symm=symm) 57 | 58 | return C 59 | 60 | def nsmatern_diag(x,diff_degree, amp=1., scale=1.,h=default_h): 61 | return (h(x)*amp)**2 62 | -------------------------------------------------------------------------------- /pymc/gp/gpplots.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from copy import copy 3 | from pymc import six 4 | 5 | __all__ = ['plot_GP_envelopes'] 6 | 7 | 8 | def plot_GP_envelopes(f, x, HPD=[ 9 | .25, .5, .95], transx=None, transy=None): 10 | """ 11 | plot_GP_envelopes(f, x[, HPD, transx, transy]) 12 | 13 | 14 | Plots centered posterior probability envelopes for f, which is a GP instance, 15 | which is a function of one variable. 16 | 17 | 18 | :Arguments: 19 | 20 | - `f`: A GaussianProcess object. 21 | 22 | - `x`: The mesh on which to plot the envelopes. 23 | 24 | - `HPD`: A list of values between 0 and 1 giving the probability mass 25 | contained in each envelope. 26 | 27 | - `transx`: Any transformation of the x-axis. 28 | 29 | - `transy`: Any transformation of the y-axis. 30 | """ 31 | try: 32 | from pymc.Matplot import centered_envelope 33 | 34 | f_trace = f.trace() 35 | x = x.ravel() 36 | N = len(f_trace) 37 | func_stacks = np.zeros((N, len(x)), dtype=float) 38 | 39 | def identity(y): 40 | return y 41 | 42 | if transy is None: 43 | transy = identity 44 | if transx is None: 45 | transx = identity 46 | 47 | # Get evaluations 48 | for i in range(N): 49 | f = copy(f_trace[i]) 50 | func_stacks[i, :] = transy(f(transx(x))) 51 | 52 | # Plot envelopes 53 | HPD = np.sort(HPD) 54 | sorted_func_stack = np.sort(func_stacks, 0) 55 | for m in HPD[::-1]: 56 | env = centered_envelope(sorted_func_stack, m) 57 | # from IPython.Debugger import Pdb 58 | # Pdb(color_scheme='LightBG').set_trace() 59 | env.display(x, alpha=1. - m * .5, new=False) 60 | centered_envelope( 61 | sorted_func_stack, 62 | 0.).display(x, 63 | alpha=1., 64 | new=False) 65 | except ImportError: 66 | six.print_('Plotter could not be imported; plotting disabled') 67 | -------------------------------------------------------------------------------- /pymc/gp/incomplete_chol.so.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.incomplete_chol.so 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /pymc/gp/linalg_utils.so.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.linalg_utils.so 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /pymc/tests/__init__.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | try: 4 | from numpy.testing import Tester 5 | 6 | with warnings.catch_warnings(): 7 | warnings.simplefilter('ignore') 8 | test = Tester().test 9 | 10 | except ImportError: 11 | warnings.warn( 12 | 'NumPy 1.2 and nose are required to run the test suite.', 13 | ImportWarning) 14 | 15 | def test(): 16 | return "Please install nose to run the test suite." 17 | -------------------------------------------------------------------------------- /pymc/tests/objectmodel.py: -------------------------------------------------------------------------------- 1 | import pymc 2 | 3 | B = pymc.Bernoulli('B', .5) 4 | 5 | 6 | class Class0(object): 7 | pass 8 | 9 | 10 | class Class1(object): 11 | pass 12 | 13 | 14 | @pymc.deterministic 15 | def K(B=B): 16 | if B: 17 | return Class0() 18 | else: 19 | return Class1() 20 | -------------------------------------------------------------------------------- /pymc/tests/test_AM.py: -------------------------------------------------------------------------------- 1 | import pymc 2 | import numpy as np 3 | 4 | from numpy.testing import * 5 | 6 | # Bivariate normal ### 7 | """We first draw random samples from a bivariate normal distribution 8 | with the following parameters: 9 | * sigma_1 = 1. 10 | * sigma_2 = sqrt(2) 11 | * rho = .8 12 | * mu = [-2., 3.]. 13 | 14 | and C = [ \sigma_1\sigma_1 \rho\sigma_1\sigma_2 ] 15 | [ \rho\sigma_2\sigma_1 \sigma_2\sigma_2 ] 16 | 17 | Then, knowing the covariance matrix C and given the random samples, 18 | we want to estimate the posterior distribution of mu. Since the prior 19 | for mu is uniform, the mean posterior distribution is simply a bivariate 20 | normal with the same correlation coefficient rho, but with variances 21 | divided by sqrt(N), where N is the number of samples drawn. 22 | 23 | We can check that the sampler works correctly by making sure that 24 | after a while, the covariance matrix of the samples for mu tend to C/N. 25 | 26 | """ 27 | N = 50 28 | mu = np.array([-2., 3.]) 29 | C = np.array([[1, .8 * np.sqrt(2)], [.8 * np.sqrt(2), 2.]]) 30 | r = pymc.rmv_normal_cov(mu, C, size=50) 31 | 32 | 33 | @pymc.stoch 34 | def mean(value=np.array([0., 0.])): 35 | """The mean of the samples (mu). """ 36 | return 0. 37 | 38 | obs = pymc.MvNormalCov('obs', mean, C, value=r, observed=True) 39 | 40 | 41 | class TestAM(TestCase): 42 | 43 | def test_convergence(self): 44 | S = pymc.MCMC([mean, obs]) 45 | S.use_step_method(pymc.AdaptiveMetropolis, mean, delay=200) 46 | 47 | S.sample(6000, burn=1000, progress_bar=0) 48 | Cs = np.cov(S.trace('mean')[:].T) 49 | assert_array_almost_equal(Cs, C / N, 2) 50 | 51 | def test_cov_from_trace(self): 52 | S = pymc.MCMC([mean, obs]) 53 | S.use_step_method(pymc.Metropolis, mean) 54 | S.sample(2000, progress_bar=0) 55 | m = S.trace('mean')[:] 56 | S.remove_step_method(S.step_method_dict[mean][0]) 57 | S.use_step_method(pymc.AdaptiveMetropolis, mean, delay=200, verbose=0) 58 | S.sample(10, progress_bar=0) 59 | AM = S.step_method_dict[mean][0] 60 | assert_almost_equal(AM.C, np.cov(m.T)) 61 | 62 | 63 | if __name__ == '__main__': 64 | import nose 65 | nose.runmodule() 66 | -------------------------------------------------------------------------------- /pymc/tests/test_GP_MCMC.py: -------------------------------------------------------------------------------- 1 | from pymc.gp import * 2 | from pymc.gp.cov_funs import matern 3 | from pymc import * 4 | from numpy import * 5 | from numpy.testing import * 6 | from numpy.random import normal 7 | 8 | 9 | # class test_MCMC(TestCase): 10 | # def test(self): 11 | 12 | x = arange(-1., 1., .1) 13 | 14 | 15 | def make_model(): 16 | # Prior parameters of C 17 | # Matern seems to be segfaulting... 18 | # diff_degree = Lognormal('diff_degree', mu=1.4, tau=100, verbose=0) 19 | diff_degree = Uniform('diff_degree', .2, 3) 20 | amp = Lognormal('amp', mu=.4, tau=1., verbose=0) 21 | scale = Lognormal('scale', mu=.5, tau=1., verbose=0) 22 | 23 | # The deterministic C is valued as a Covariance object. 24 | @deterministic(verbose=0) 25 | def C(eval_fun=matern.euclidean, 26 | diff_degree=diff_degree, amp=amp, scale=scale): 27 | return Covariance( 28 | eval_fun, diff_degree=diff_degree, amp=amp, scale=scale) 29 | 30 | # Prior parameters of M 31 | a = Normal('a', mu=1., tau=1., verbose=0) 32 | b = Normal('b', mu=.5, tau=1., verbose=0) 33 | c = Normal('c', mu=2., tau=1., verbose=0) 34 | 35 | # The mean M is valued as a Mean object. 36 | def linfun(x, a, b, c): 37 | return a * x ** 2 + b * x + c 38 | 39 | @deterministic(verbose=0) 40 | def M(eval_fun=linfun, a=a, b=b, c=c): 41 | return Mean(eval_fun, a=a, b=b, c=c) 42 | 43 | # The GP itself 44 | fmesh = array([-.5, .5]) 45 | submod = GPSubmodel('submodel', M, C, fmesh) 46 | 47 | # Observation precision 48 | V = Gamma('V', alpha=3., beta=.002 / 3., verbose=0) 49 | 50 | # The data d is just array-valued. It's normally distributed about 51 | # GP.f(obs_x). 52 | @observed(verbose=0) 53 | def d(value=array([3.1, 2.9]), mu=submod.f, V=V, verbose=0): 54 | """ 55 | Data 56 | """ 57 | mu_eval = mu(fmesh) 58 | return flib.normal(value, mu_eval, 1. / V) 59 | 60 | return locals() 61 | 62 | GPSampler = MCMC(make_model()) 63 | GPSampler.use_step_method( 64 | gp.GPEvaluationGibbs, 65 | GPSampler.submod, 66 | GPSampler.V, 67 | GPSampler.d) 68 | GPSampler.assign_step_methods() 69 | GPSampler.sample(iter=500, burn=0, thin=10, progress_bar=0) 70 | # 71 | # if __name__ == '__main__': 72 | # import unittest 73 | # unittest.main() 74 | -------------------------------------------------------------------------------- /pymc/tests/test_MCMCSampler.py: -------------------------------------------------------------------------------- 1 | """ 2 | The DisasterMCMC example. 3 | 4 | """ 5 | from __future__ import with_statement 6 | from numpy.testing import * 7 | from pymc import MCMC, database 8 | from pymc.examples import disaster_model 9 | import nose 10 | import warnings 11 | import os 12 | import shutil 13 | 14 | PLOT = True 15 | try: 16 | from pymc.Matplot import plot, autocorrelation 17 | except: 18 | PLOT = False 19 | pass 20 | 21 | 22 | DIR = 'testresults/' 23 | 24 | 25 | class test_tiny_MCMC(TestCase): 26 | 27 | # Instantiate samplers 28 | M = MCMC(disaster_model) 29 | 30 | # Sample 31 | M.sample(10, progress_bar=False) 32 | 33 | def test_plot(self): 34 | 35 | if not PLOT: 36 | raise nose.SkipTest 37 | 38 | # Plot samples 39 | plot(self.M, path=DIR, verbose=0) 40 | 41 | 42 | class test_MCMC(TestCase): 43 | 44 | dbname=DIR+'test_MCMC' 45 | 46 | if not os.path.exists(DIR): 47 | os.mkdir(DIR) 48 | 49 | # Instantiate samplers 50 | M = MCMC(disaster_model, db='txt', dbname=dbname) 51 | 52 | # Sample 53 | M.sample(2000, 100, thin=15, verbose=0, progress_bar=False) 54 | 55 | def test_instantiation(self): 56 | 57 | # Check stochastic arrays 58 | assert_equal(len(self.M.stochastics), 3) 59 | assert_equal(len(self.M.observed_stochastics), 1) 60 | assert_array_equal( 61 | self.M.disasters.value, 62 | disaster_model.disasters_array) 63 | 64 | def test_plot(self): 65 | if not PLOT: 66 | raise nose.SkipTest 67 | 68 | # Plot samples 69 | plot(self.M.early_mean, path=DIR, verbose=0) 70 | 71 | def test_autocorrelation(self): 72 | if not PLOT: 73 | raise nose.SkipTest 74 | 75 | # Plot samples 76 | autocorrelation(self.M.early_mean, path=DIR, verbose=0) 77 | 78 | def test_stats(self): 79 | S = self.M.early_mean.stats() 80 | self.M.stats() 81 | 82 | def test_float_iter(self): 83 | self.M.sample(10.5, verbose=0, progress_bar=False) 84 | 85 | 86 | if __name__ == '__main__': 87 | 88 | original_filters = warnings.filters[:] 89 | warnings.simplefilter("ignore") 90 | try: 91 | import nose 92 | nose.runmodule() 93 | finally: 94 | warnings.filters = original_filters 95 | 96 | # TODO: Restore in 2.2 97 | # with warnings.catch_warnings(): 98 | # warnings.simplefilter('ignore', FutureWarning) 99 | # nose.runmodule() 100 | -------------------------------------------------------------------------------- /pymc/tests/test_adaptive.py: -------------------------------------------------------------------------------- 1 | from __future__ import with_statement 2 | 3 | """Test AdaptiveMetropolis.""" 4 | import pymc 5 | import numpy as np 6 | from numpy.testing import * 7 | import nose 8 | import warnings 9 | 10 | 11 | def test_square(): 12 | iw = pymc.Wishart("A", 2, np.eye(2)) 13 | mnc = pymc.MvNormal( 14 | "v", 15 | np.zeros(2), 16 | iw, 17 | value=np.zeros(2), 18 | observed=True) 19 | 20 | M = pymc.MCMC([iw, mnc]) 21 | M.sample(8, progress_bar=0) 22 | 23 | 24 | if __name__ == '__main__': 25 | 26 | original_filters = warnings.filters[:] 27 | warnings.simplefilter("ignore") 28 | try: 29 | nose.runmodule() 30 | finally: 31 | warnings.filters = original_filters 32 | 33 | # TODO: Restore this implementation in 2.2 34 | # with warnings.catch_warnings(): 35 | # warnings.simplefilter('ignore', FutureWarning) 36 | # nose.runmodule() 37 | -------------------------------------------------------------------------------- /pymc/tests/test_basiscov.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import * 2 | from pymc.gp import * 3 | from pymc.gp.cov_funs import * 4 | from numpy import * 5 | from copy import copy 6 | 7 | from pymc import six 8 | xrange = six.moves.xrange 9 | 10 | random.seed(42) 11 | 12 | def zero_fun(x): 13 | return zeros(x.shape[:-1], dtype=float) 14 | M = Mean(zero_fun) 15 | 16 | lin = linspace(-1., 1., 50) 17 | x, y = meshgrid(lin, lin) 18 | xstack = zeros(x.shape + (2,), dtype=float) 19 | xstack[:, :, 0] = x 20 | xstack[:, :, 1] = y 21 | 22 | lin_obs = linspace(-.5, .5, 2) 23 | xobs, yobs = meshgrid(lin_obs, lin_obs) 24 | ostack = zeros(xobs.shape + (2,), dtype=float) 25 | ostack[:, :, 0] = xobs 26 | ostack[:, :, 1] = yobs 27 | 28 | V = .02 * ones((2, 2), dtype=float) 29 | data = ones((2, 2), dtype=float) 30 | N = 10 31 | 32 | coef_cov = ones((2 * N + 1, 2 * N + 1), dtype=float) 33 | for i in xrange(1, 2 * N + 1): 34 | int_i = int(((i + 1) / 2)) 35 | for j in xrange(1, 2 * N + 1): 36 | int_j = int(((j + 1) / 2)) 37 | coef_cov[i, j] = 1. / (sqrt((int_i + int_j) ** 2)) ** 2.5 38 | 39 | basis = fourier_basis([N, N]) 40 | C = SeparableBasisCovariance(basis, coef_cov, xmin=[-4., -.4], xmax=[4., 4.]) 41 | 42 | 43 | class test_basiscov(TestCase): 44 | 45 | def test_sep(self): 46 | 47 | observe(M, C, obs_mesh=ostack, obs_V=V, obs_vals=data) 48 | 49 | def test_nonsep(self): 50 | 51 | basis_array = zeros((2 * N + 1, 2 * N + 1), dtype=object) 52 | for i in arange(2 * N + 1): 53 | 54 | if i % 2 == 0: 55 | def funi(x, xmin, xmax, i=i): 56 | T = xmax[0] - xmin[0] 57 | return cos(i * pi * (x - xmin[0]) / T) 58 | 59 | else: 60 | def funi(x, xmin, xmax, i=i): 61 | T = xmax[0] - xmin[0] 62 | return sin((i + 1) * pi * (x - xmin[0]) / T) 63 | 64 | for j in arange(2 * N + 1): 65 | 66 | if j % 2 == 0: 67 | def funj(x, xmin, xmax, j=j): 68 | T = xmax[1] - xmin[1] 69 | return cos(j * pi * (x - xmin[1]) / T) 70 | else: 71 | def funj(x, xmin, xmax, j=j): 72 | T = xmax[1] - xmin[1] 73 | return sin((j + 1) * pi * (x - xmin[1]) / T) 74 | 75 | def fun_now(x, xmin, xmax, funi=funi, funj=funj): 76 | return funi(x[:, 0], xmin, xmax) * \ 77 | funj(x[:, 1], xmin, xmax) 78 | 79 | basis_array[i, j] = fun_now 80 | 81 | C2 = BasisCovariance( 82 | basis_array, coef_cov, xmin=[-4., -.4], xmax=[4., 4.]) 83 | assert_almost_equal(C2(xstack), C(xstack)) 84 | 85 | observe(M, C, obs_mesh=ostack, obs_V=V, obs_vals=data) 86 | -------------------------------------------------------------------------------- /pymc/tests/test_binary_step.py: -------------------------------------------------------------------------------- 1 | """Test the binary step method. 2 | Assume we have a series of heads (0) or tail (1) experiments : 3 | [0,0,1,1,0,0,0,1,1,0] 4 | Assume that the coin is either fair (p=.5), or unfair (p!=.5). 5 | We have two parameters: 6 | * fair : which can be True or False, 7 | * coin : the probability of tail on flipping the coin 8 | """ 9 | 10 | from numpy.testing import TestCase 11 | import pymc 12 | import numpy as np 13 | 14 | 15 | class BinaryTestModel: 16 | series = np.array([0, 0, 1, 1, 0, 0, 0, 1, 1, 1]) 17 | 18 | fair = pymc.Bernoulli('fair', p=.5, value=1) 19 | 20 | @pymc.deterministic 21 | def coin(fair=fair): 22 | if fair: 23 | return .5 24 | else: 25 | return .1 26 | # @stoch 27 | # def coin(value=.5, fair=fair): 28 | # """Return the probability of a tail on flipping a coin.""" 29 | # if fair is True: 30 | # return pymc.beta_like(value, 1e6, 1e6) 31 | # else: 32 | # return pymc.uniform_like(value, .3, .7) 33 | 34 | tail = pymc.Bernoulli('tail', p=coin, value=series, observed=True) 35 | 36 | 37 | class TestBinary(TestCase): 38 | 39 | def test(self): 40 | S = pymc.MCMC(input=BinaryTestModel) 41 | S.sample(1000, 500, progress_bar=0) 42 | f = S.fair.trace() 43 | assert(1.0 * f.sum() / len(f) > .5) 44 | 45 | if __name__ == '__main__': 46 | import unittest 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /pymc/tests/test_container.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import * 2 | from numpy import * 3 | from pymc.examples import disaster_model as DM 4 | from pymc import Container, Normal 5 | 6 | 7 | class test_Container(TestCase): 8 | 9 | def test_container_parents(self): 10 | A = Normal('A', 0, 1) 11 | B = Normal('B', 0, 1) 12 | 13 | C = Normal('C', [A, B], 1) 14 | 15 | assert_equal(Container([A, B]).value, [A.value, B.value]) 16 | assert_equal(C.parents.value['mu'], [A.value, B.value]) 17 | 18 | def test_nested_tuple_container(self): 19 | A = Normal('A', 0, 1) 20 | try: 21 | Container(([A],)) 22 | raise AssertionError('A NotImplementedError should have resulted.') 23 | except NotImplementedError: 24 | pass 25 | 26 | def test(self): 27 | 28 | # Test set container: 29 | 30 | S = [DM.early_mean, DM.switchpoint, DM.late_mean] 31 | R = Container(S) 32 | 33 | for item in R: 34 | assert(item in S) 35 | 36 | for item in R.value: 37 | val_in_S = False 38 | for S_item in S: 39 | if S_item.value is item: 40 | val_in_S = True 41 | 42 | assert(val_in_S) 43 | 44 | # Test list/dictionary container: 45 | 46 | A = [[DM.early_mean, DM.switchpoint], 47 | [DM.late_mean, DM.disasters, 3.], 54.323] 48 | C = Container(A) 49 | 50 | for i in range(2): 51 | for j in range(2): 52 | assert(C[i][j] == A[i][j]) 53 | assert(all(C.value[i][j] == A[i][j].value)) 54 | 55 | assert(C[1][2] == A[1][2]) 56 | assert(C.value[1][2] == A[1][2]) 57 | 58 | assert(C[2] == A[2]) 59 | assert(C.value[2] == A[2]) 60 | 61 | # Test array container: 62 | 63 | B = ndarray((3, 3), dtype=object) 64 | B[0, :] = DM.early_mean 65 | B[1, :] = 1. 66 | B[2, :] = A 67 | D = Container(B) 68 | 69 | for i in range(2): 70 | assert(D[0, i] == DM.early_mean) 71 | assert(D.value[0, i] == DM.early_mean.value) 72 | assert(D[1, i] == 1.) 73 | assert(D.value[1, i] == 1.) 74 | 75 | P = D[2, :] 76 | Q = D.value[2, :] 77 | 78 | for i in range(2): 79 | for j in range(2): 80 | assert(P[i][j] == A[i][j]) 81 | assert(all(Q[i][j] == A[i][j].value)) 82 | 83 | assert(P[1][2] == A[1][2]) 84 | assert(Q[1][2] == A[1][2]) 85 | 86 | assert(P[2] == A[2]) 87 | assert(Q[2] == A[2]) 88 | 89 | 90 | if __name__ == '__main__': 91 | import unittest 92 | unittest.main() 93 | -------------------------------------------------------------------------------- /pymc/tests/test_cov.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import * 2 | from pymc.gp import * 3 | from pymc.gp.cov_funs import matern 4 | from numpy import * 5 | from copy import copy 6 | from .test_mean import x, y 7 | 8 | C = Covariance( 9 | eval_fun=matern.euclidean, 10 | diff_degree=1.4, 11 | amp=.4, 12 | scale=1.) 13 | D = copy(C) 14 | 15 | 16 | class test_cov(TestCase): 17 | 18 | def test(self): 19 | 20 | assert(C(x).shape == x.shape) 21 | assert(C(x, x).shape == (len(x), len(x))) 22 | 23 | assert(D(y).shape == (y.shape[0],)) 24 | assert(D(y, y).shape == (y.shape[0], y.shape[0])) 25 | -------------------------------------------------------------------------------- /pymc/tests/test_graph.py: -------------------------------------------------------------------------------- 1 | import pymc as pm 2 | from numpy.testing import * 3 | import numpy as np 4 | import nose 5 | import sys 6 | 7 | from pymc import six 8 | xrange = six.moves.xrange 9 | 10 | DIR = 'testresults' 11 | 12 | 13 | def mymodel(): 14 | mu = pm.Normal('mu', 0, 1) 15 | N = [pm.Normal('N_%i' % i, mu, 1) for i in xrange(3)] 16 | z1 = pm.Lambda('z1', lambda n=N: np.sum(n)) 17 | z2 = pm.Lambda('z2', lambda n=N: np.sum(n)) 18 | 19 | @pm.potential 20 | def y(z1=z1, z2=z2, mu=mu): 21 | return 0 22 | return mu, N, z1, z2, y 23 | 24 | 25 | def powerset(seq): 26 | """ 27 | Returns all the subsets of this set. This is a generator. 28 | 29 | From http://blog.technomancy.org/2009/3/17/a-powerset-generator-in-python 30 | """ 31 | if len(seq) <= 1: 32 | yield seq 33 | yield [] 34 | else: 35 | for item in powerset(seq[1:]): 36 | yield [seq[0]] + item 37 | yield item 38 | 39 | class test_graph(TestCase): 40 | 41 | @dec.skipif(sys.version_info.major==3) 42 | def test_graph(self): 43 | try: 44 | import pydot 45 | except ImportError: 46 | raise nose.SkipTest 47 | mu, N, z1, z2, y = mymodel() 48 | for mods in [[mu], [mu, N], [mu, N, z1, z2], [mu, N, z1, z2, y]]: 49 | for args in powerset([('collapse_deterministics', True), ('collapse_potentials', True), ('label_edges', False), ('legend', True), ('consts', True)]): 50 | M = pm.Model(mods) 51 | pm.graph.graph(M, path=DIR, **dict(args)) 52 | 53 | @dec.skipif(sys.version_info.major==3) 54 | def test_moral(self): 55 | try: 56 | import pydot 57 | except ImportError: 58 | raise nose.SkipTest 59 | mu, N, z1, z2, y = mymodel() 60 | for mods in [[mu], [mu, N], [mu, N, z1, z2], [mu, N, z1, z2, y]]: 61 | M = pm.Model(mods) 62 | pm.graph.moral_graph(M, path=DIR) 63 | 64 | 65 | if __name__ == '__main__': 66 | C = nose.config.Config(verbosity=1) 67 | nose.runmodule(config=C) 68 | -------------------------------------------------------------------------------- /pymc/tests/test_interactive.py: -------------------------------------------------------------------------------- 1 | """ 2 | Test interactive sampler 3 | """ 4 | 5 | # TODO: Make real test case. 6 | 7 | from pymc import MCMC 8 | from pymc.examples import disaster_model 9 | import os 10 | import nose 11 | 12 | 13 | def test_interactive(): 14 | S = MCMC(disaster_model) 15 | S.isample( 16 | 200, 17 | 100, 18 | 2, 19 | out=open( 20 | 'testresults/interactive.log', 21 | 'w'), 22 | progress_bar=0) 23 | 24 | 25 | if __name__ == '__main__': 26 | nose.runmodule() 27 | -------------------------------------------------------------------------------- /pymc/tests/test_mean.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import * 2 | from numpy import * 3 | from pymc.gp import Mean 4 | from copy import copy 5 | 6 | 7 | def quadfun(x, a, b, c): 8 | return (a * x ** 2 + b * x + c) 9 | 10 | M = Mean(eval_fun=quadfun, a=1., b=.5, c=2.) 11 | 12 | 13 | def constant(x, val): 14 | """docstring for parabolic_fun""" 15 | return zeros(x.shape[:-1], dtype=float) + val 16 | 17 | N = Mean(constant, val=0.) 18 | 19 | x = arange(-1, 1, .01) 20 | y = vstack((x, x)).T 21 | 22 | 23 | class test_mean(TestCase): 24 | 25 | def test(self): 26 | assert(M(x).shape == x.shape) 27 | assert(N(y).shape == (y.shape[0],)) 28 | -------------------------------------------------------------------------------- /pymc/tests/test_missing.py: -------------------------------------------------------------------------------- 1 | from pymc import rnormal, Normal, MCMC, Uniform, Metropolis 2 | from numpy import ma, shape, ravel 3 | from numpy.testing import * 4 | 5 | # Generate some data with missing observations 6 | fake_data = rnormal(0, 1, size=100) 7 | m = ma.masked_array(fake_data) 8 | m[[3, 6]] = ma.masked 9 | m.fill_value = -4 10 | 11 | 12 | class TestMissing(TestCase): 13 | 14 | """Unit test for missing data imputation""" 15 | 16 | def test_simple(self): 17 | 18 | # Priors 19 | mu = Normal('mu', mu=0, tau=0.0001) 20 | s = Uniform('s', lower=0, upper=100, value=10) 21 | tau = s ** -2 22 | 23 | # Likelihood with missing data 24 | x = Normal('x', mu=mu, tau=tau, value=m, observed=True) 25 | 26 | # Instantiate sampler 27 | M = MCMC([mu, s, tau, x]) 28 | 29 | # Run sampler 30 | M.sample(10000, 5000, progress_bar=0) 31 | 32 | # Check length of value 33 | assert_equal(len(x.value), 100) 34 | # Check size of trace 35 | tr = M.trace('x')() 36 | assert_equal(shape(tr), (5000, 2)) 37 | 38 | sd2 = [-2 < i < 2 for i in ravel(tr)] 39 | 40 | # Check for standard normal output 41 | assert_almost_equal(sum(sd2) / 10000., 0.95, decimal=1) 42 | 43 | def test_non_missing(self): 44 | """ 45 | Test to ensure that masks without any missing values are not imputed. 46 | """ 47 | 48 | fake_data = rnormal(0, 1, size=10) 49 | m = ma.masked_array(fake_data, fake_data == -999) 50 | 51 | # Priors 52 | mu = Normal('mu', mu=0, tau=0.0001) 53 | s = Uniform('s', lower=0, upper=100, value=10) 54 | tau = s ** -2 55 | 56 | # Likelihood with missing data 57 | x = Normal('x', mu=mu, tau=tau, value=m, observed=True) 58 | 59 | # Instantiate sampler 60 | M = MCMC([mu, s, tau, x]) 61 | 62 | # Run sampler 63 | M.sample(20000, 19000, progress_bar=0) 64 | 65 | # Ensure likelihood does not have a trace 66 | assert_raises(AttributeError, x.__getattribute__, 'trace') 67 | -------------------------------------------------------------------------------- /pymc/tests/test_norm_approx.py: -------------------------------------------------------------------------------- 1 | from pymc import NormApprox 2 | from pymc.examples import gelman_bioassay 3 | try: 4 | from pylab import * 5 | except: 6 | pass 7 | 8 | from numpy import * 9 | from numpy.testing import * 10 | from numpy.linalg import cholesky 11 | import nose 12 | PLOT = False 13 | 14 | model = gelman_bioassay 15 | 16 | 17 | class test_norm_approx(TestCase): 18 | 19 | @classmethod 20 | def setUpClass(self): 21 | try: 22 | import scipy 23 | except: 24 | raise nose.SkipTest("SciPy not installed.") 25 | 26 | def test_fmin(self): 27 | N = NormApprox(model) 28 | N.fit('fmin') 29 | 30 | def test_fmin_l_bfgs_b(self): 31 | N = NormApprox(model) 32 | N.fit('fmin_l_bfgs_b') 33 | 34 | def test_fmin_ncg(self): 35 | N = NormApprox(model) 36 | N.fit('fmin_ncg') 37 | 38 | def test_fmin_cg(self): 39 | N = NormApprox(model) 40 | N.fit('fmin_cg') 41 | 42 | def test_fmin_powell(self): 43 | N = NormApprox(model) 44 | N.fit('fmin_powell') 45 | 46 | def test_revert(self): 47 | N = NormApprox(model) 48 | N.fit() 49 | max_alpha = N.alpha.value.copy() 50 | N.alpha.random() 51 | N.revert_to_max() 52 | assert_almost_equal(N.alpha.value, max_alpha) 53 | 54 | def test_sig(self): 55 | N = NormApprox(model) 56 | N.fit('fmin') 57 | assert((abs(N._sig * N._sig.T - N._C) < 1.0e-14).all()) 58 | 59 | def test_get(self): 60 | N = NormApprox(model) 61 | N.fit('fmin') 62 | N.mu[N.alpha, N.beta] 63 | N.C[N.alpha, N.beta] 64 | 65 | def test_draws(self): 66 | N = NormApprox(model) 67 | N.fit('fmin') 68 | N.sample(1000) 69 | if PLOT: 70 | plot(N.alpha.trace(), N.beta.trace(), 'k.') 71 | xlabel(r'$\alpha$') 72 | ylabel(r'$\beta$') 73 | 74 | if __name__ == '__main__': 75 | import unittest 76 | unittest.main() 77 | -------------------------------------------------------------------------------- /pymc/tests/test_observation.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import * 2 | from pymc.gp import * 3 | from .test_mean import M, x 4 | from .test_cov import C 5 | from numpy import * 6 | from copy import copy 7 | 8 | M = copy(M) 9 | C = copy(C) 10 | 11 | # Impose observations on the GP 12 | 13 | 14 | class test_observation(TestCase): 15 | 16 | def test(self): 17 | 18 | obs_x = array([-.5, .5]) 19 | V = array([.002, .002]) 20 | data = array([3.1, 2.9]) 21 | observe(M=M, 22 | C=C, 23 | obs_mesh=obs_x, 24 | obs_V=V, 25 | obs_vals=data) 26 | 27 | # Generate realizations 28 | 29 | for i in range(3): 30 | f = Realization(M, C) 31 | f(x) 32 | -------------------------------------------------------------------------------- /pymc/tests/test_realization.py: -------------------------------------------------------------------------------- 1 | from numpy.testing import * 2 | from pymc.gp import * 3 | from .test_mean import M, x 4 | from .test_cov import C 5 | from numpy import * 6 | from copy import copy 7 | 8 | # Impose observations on the GP 9 | 10 | 11 | class test_realization(TestCase): 12 | 13 | def test(self): 14 | for i in range(3): 15 | f = Realization(M, C) 16 | f(x) 17 | -------------------------------------------------------------------------------- /pymc/tests/test_slice.py: -------------------------------------------------------------------------------- 1 | import pymc 2 | from pymc.examples import gelman_bioassay 3 | import numpy as np 4 | from numpy.testing import * 5 | 6 | # Easy dice example (analytically solvable) 7 | 8 | 9 | def dice(data=None): 10 | 11 | if data is None: 12 | x = [pymc.rbernoulli(1.0 / 6.0) for i in range(0, 100)] 13 | else: 14 | x = data 15 | 16 | prob = pymc.Uniform('prob', lower=0, upper=1) 17 | 18 | d = pymc.Bernoulli('d', p=prob, value=x, observed=True) 19 | 20 | return locals() 21 | 22 | 23 | class TestSlice(TestCase): 24 | 25 | def test_dice_sample(self): 26 | M = pymc.MCMC(dice()) 27 | M.use_step_method(pymc.Slicer, M.prob, w=.1) 28 | M.sample(iter=1000, tune_interval=1) 29 | 30 | def test_bioassay_sample(self): 31 | M = pymc.MCMC(gelman_bioassay) 32 | for stoch in M.stochastics: 33 | M.use_step_method(pymc.Slicer, stoch, w=.1) 34 | M.sample(iter=1000, tune_interval=1) 35 | -------------------------------------------------------------------------------- /pymc/tests/test_utils.py: -------------------------------------------------------------------------------- 1 | from pymc import * 2 | from numpy import * 3 | from numpy.testing import * 4 | import nose 5 | import sys 6 | from pymc import utils 7 | 8 | from pymc import six 9 | xrange = six.moves.xrange 10 | 11 | class test_logp_of_set(TestCase): 12 | A = Normal('A', 0, 1) 13 | B = Gamma('B', 1, 1) 14 | C = Lambda('C', lambda b=B: sqrt(b)) 15 | D = Gamma('D', C, 1) 16 | 17 | @stochastic 18 | def E(x=1, value=3): 19 | if value != 3: 20 | raise RuntimeError 21 | else: 22 | return 0. 23 | E.value = 2 24 | 25 | def test_logp(self): 26 | self.B.rand() 27 | lp1 = utils.logp_of_set(set([self.A, self.B, self.D])) 28 | assert_almost_equal(lp1, self.A.logp + self.B.logp + self.D.logp, 10) 29 | 30 | def test_ZeroProb(self): 31 | self.B.value = -1 32 | for i in xrange(1000): 33 | try: 34 | utils.logp_of_set(set([self.A, self.B, self.D, self.E])) 35 | except: 36 | cls, inst, tb = sys.exc_info() 37 | assert(cls is ZeroProbability) 38 | 39 | def test_other_err(self): 40 | self.B.rand() 41 | for i in xrange(1000): 42 | try: 43 | utils.logp_of_set(set([self.A, self.B, self.D, self.E])) 44 | except: 45 | cls, inst, tb = sys.exc_info() 46 | assert(cls is RuntimeError) 47 | 48 | 49 | class test_normcdf_input_shape(TestCase): 50 | 51 | def test_normcdf_1d_input(self): 52 | x = arange(8.) 53 | utils.normcdf(x) 54 | 55 | def test_normcdf_log_1d_input(self): 56 | x = arange(8.) 57 | utils.normcdf(x, log=True) 58 | 59 | def test_normcdf_2d_input(self): 60 | x = arange(8.).reshape(2, 4) 61 | utils.normcdf(x) 62 | 63 | def test_normcdf_log_2d_input(self): 64 | x = arange(8.).reshape(2, 4) 65 | utils.normcdf(x, log=True) 66 | 67 | def test_normcdf_3d_input(self): 68 | x = arange(8.).reshape(2, 2, 2) 69 | utils.normcdf(x) 70 | 71 | def test_normcdf_log_3d_input(self): 72 | x = arange(8.).reshape(2, 2, 2) 73 | utils.normcdf(x, log=True) 74 | 75 | class test_invcdf_input_shape(TestCase): 76 | 77 | def test_invcdf_1d_input(self): 78 | x = random.random(8) 79 | utils.invcdf(x) 80 | 81 | def test_invcdf_2d_input(self): 82 | x = random.random((2, 4)) 83 | utils.invcdf(x) 84 | 85 | def test_invcdf_3d_input(self): 86 | x = random.random((2, 2, 2)) 87 | utils.invcdf(x) 88 | 89 | if __name__ == '__main__': 90 | C = nose.config.Config(verbosity=1) 91 | nose.runmodule(config=C) 92 | -------------------------------------------------------------------------------- /setupegg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | A setup.py script to use setuptools, which gives egg goodness, etc. 4 | """ 5 | 6 | from setuptools import setup 7 | with open('setup.py') as s: 8 | exec(s.read()) 9 | -------------------------------------------------------------------------------- /stdeb_all.cfg: -------------------------------------------------------------------------------- 1 | ########## WARNING: This file is not (anywhere near) perfect! I haven't 2 | # spent enough time understanding Debian Python policy and examing other 3 | # packages. Eventually I will do so, and I would welcome help. 4 | 5 | # You have been warned, use at your own risk. 6 | 7 | [pymc] 8 | Depends: python (>= 2.5.0), python-numpy (>= 1.1.1), python-scipy, python-matplotlib, python-tables 9 | Build-Depends: gfortran, python-numpy 10 | 11 | # [setuptools] 12 | # Source: setuptools 13 | # #Debian-Version: 0ads1 14 | # Provides: python2.5-setuptools 15 | # Conflicts: python2.5-setuptools, python2.4-setuptools 16 | # Replaces: python2.5-setuptools 17 | # 18 | # [numpy] 19 | # Source: numpy 20 | # # Debian-Version: 0ads3 21 | # Build-Depends: python-dev, refblas3-dev | atlas3-base-dev, lapack3-dev | atlas3-base-dev 22 | # Provides: python2.5-numpy 23 | # Conflicts: python2.5-numpy, python2.4-numpy 24 | # Replaces: python2.5-numpy 25 | # 26 | # [matplotlib] 27 | # # (For some reason, "debuild -sa" won't build matplotlib because tk.h isn't found.) 28 | # Build-Depends: python-dev, python-numpy, python-numarray, python-numeric, python-gtk2-dev, tk8.4-dev, libwxgtk2.4-dev, python-tz 29 | # Depends: python-gtk2, python-numpy, python-numeric, python-numarray, python-tz 30 | # Suggests: gs-gpl 31 | # # When building non-release, uncomment this: (Is this still necessary?) 32 | # #Upstream-Version-Suffix: .dev-r2587 33 | # # When building release, uncommend this: (This should get fixed upstream.) 34 | # # Stdeb-Patch-File: /home/astraw/other-peoples-src/matplotlib/mpl_no_egg_info.patch 35 | # Provides: python2.5-matplotlib, python-matplotlib-data 36 | # Conflicts: python2.5-matplotlib, python-matplotlib-data 37 | # Replaces: python2.5-matplotlib, python-matplotlib-data 38 | # 39 | # [scipy] 40 | # Debian-Version: 0ads1 41 | # Source: scipy 42 | # #Upstream-Version-Prefix: 0.4.9+ 43 | # Build-Depends: python-numpy, fftw3-dev 44 | # Depends: python-numpy 45 | # Provides: python2.5-scipy 46 | # Conflicts: python2.5-scipy, python2.4-scipy 47 | # Replaces: python2.5-scipy 48 | # 49 | # [tables] 50 | # Debian-Version: 0ads2 51 | # Source: pytables 52 | # #Upstream-Version-Suffix: .svn1713 53 | # Build-Depends: libhdf5-serial-dev, python-numarray, libbz2-dev, liblzo-dev 54 | # Depends: python-numarray, python-numpy 55 | # Provides: python2.5-tables 56 | # Conflicts: python2.5-tables, python2.4-tables 57 | # Replaces: python2.5-tables --------------------------------------------------------------------------------