├── .gitignore ├── .travis.yml ├── LICENSE ├── MANIFEST.in ├── README.rst ├── demo ├── demo.py ├── sample_data_core.pkl └── sample_data_edge.pkl ├── docs ├── Makefile ├── build │ ├── doctrees │ │ ├── environment.pickle │ │ ├── gptools.doctree │ │ ├── gptools.kernel.doctree │ │ ├── index.doctree │ │ └── modules.doctree │ ├── html │ │ ├── .buildinfo │ │ ├── _images │ │ │ └── math │ │ │ │ ├── 0024155eabfcd1190d07f9520b42da07cc573f98.png │ │ │ │ ├── 15c0e5b01b2bdc6a5ed2eea279f4c2f2b7cfd70b.png │ │ │ │ ├── 172e6dadffd9800e796f3f96a1e24ce2a1840f3a.png │ │ │ │ ├── 2be7268c95610c46b5939dc92d48f8a5eea456ab.png │ │ │ │ ├── 3e4706baa604e1794d41d43400ba7708395a055b.png │ │ │ │ ├── 3f243899bc87ead4773f775f234b52af69f27836.png │ │ │ │ ├── 57a710d686452bd0ecc177300d3e523c300445a3.png │ │ │ │ ├── 57ff4ac903860e9b65cecd0a4d38e725be98ec86.png │ │ │ │ ├── 5e1668792d162faf7f4c6f233fcf3fda1b4f8592.png │ │ │ │ ├── 6555583597f0140ab50c633f415f7b24ae12ce8d.png │ │ │ │ ├── 7198c11f22989d15f71fc60acc87c66017ea5e94.png │ │ │ │ ├── 897470a282b6b85fa5221eacd41369b9a157f491.png │ │ │ │ ├── 9ad99798ec4c38e165cf517cb9e02b1c9e824103.png │ │ │ │ ├── 9c8517c8f741ce57640333495649385dd9f0c8cc.png │ │ │ │ ├── a6b81ac9039f9854754a5a0ccb8f93d66b4e3fec.png │ │ │ │ ├── afed7b6656e31605fbc89857f1260a9e62dda899.png │ │ │ │ ├── b339c4c45440f4de3adc6c7b8f87571841bed3c0.png │ │ │ │ ├── c440ab49d1eecb2a30a497bb59468065541125f8.png │ │ │ │ ├── ce3fbc71c8696e043988d37d4140479fa0b6940b.png │ │ │ │ ├── d6a7ccf879c4a4fe694033606332cb83806db296.png │ │ │ │ ├── d988f25fabbe6e8d7295e0b08ae4a3c48a89004e.png │ │ │ │ ├── e186cdff23ad92dbe25521fcb875ef7618df6284.png │ │ │ │ ├── f49377a915206cf8e5956a4c388e1ca70c048f57.png │ │ │ │ └── fb8eb09dd92824edc267624b0de1ed9eb5431d77.png │ │ ├── _modules │ │ │ ├── gptools │ │ │ │ ├── error_handling.html │ │ │ │ ├── gaussian_process.html │ │ │ │ ├── kernel │ │ │ │ │ ├── core.html │ │ │ │ │ ├── gibbs.html │ │ │ │ │ ├── matern.html │ │ │ │ │ ├── noise.html │ │ │ │ │ ├── rational_quadratic.html │ │ │ │ │ └── squared_exponential.html │ │ │ │ └── utils.html │ │ │ └── index.html │ │ ├── _sources │ │ │ ├── gptools.kernel.txt │ │ │ ├── gptools.txt │ │ │ ├── index.txt │ │ │ └── modules.txt │ │ ├── _static │ │ │ ├── ajax-loader.gif │ │ │ ├── basic.css │ │ │ ├── comment-bright.png │ │ │ ├── comment-close.png │ │ │ ├── comment.png │ │ │ ├── default.css │ │ │ ├── doctools.js │ │ │ ├── down-pressed.png │ │ │ ├── down.png │ │ │ ├── file.png │ │ │ ├── jquery.js │ │ │ ├── minus.png │ │ │ ├── plus.png │ │ │ ├── pygments.css │ │ │ ├── searchtools.js │ │ │ ├── sidebar.js │ │ │ ├── underscore.js │ │ │ ├── up-pressed.png │ │ │ ├── up.png │ │ │ └── websupport.js │ │ ├── genindex.html │ │ ├── gptools.html │ │ ├── gptools.kernel.html │ │ ├── index.html │ │ ├── modules.html │ │ ├── np-modindex.html │ │ ├── objects.inv │ │ ├── py-modindex.html │ │ ├── search.html │ │ └── searchindex.js │ └── latex │ │ ├── Makefile │ │ ├── fncychap.sty │ │ ├── gptools.aux │ │ ├── gptools.idx │ │ ├── gptools.ilg │ │ ├── gptools.ind │ │ ├── gptools.log │ │ ├── gptools.out │ │ ├── gptools.pdf │ │ ├── gptools.tex │ │ ├── gptools.toc │ │ ├── python.ist │ │ ├── sphinx.sty │ │ ├── sphinxhowto.cls │ │ ├── sphinxmanual.cls │ │ └── tabulary.sty ├── make.bat └── source │ ├── conf.py │ ├── gptools.kernel.rst │ ├── gptools.rst │ ├── index.rst │ ├── modules.rst │ └── readthedocs-pip-requirements.txt ├── gptools ├── __init__.py ├── error_handling.py ├── gaussian_process.py ├── gp_utils.py ├── kernel │ ├── __init__.py │ ├── _matern.pyx │ ├── core.py │ ├── gibbs.py │ ├── include │ │ └── matern.h │ ├── matern.py │ ├── noise.py │ ├── rational_quadratic.py │ ├── squared_exponential.py │ ├── src │ │ └── matern.c │ └── warping.py ├── mean.py ├── splines.py └── utils.py ├── setup.py └── tests └── test_matern.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | eggs/ 15 | lib/ 16 | lib64/ 17 | parts/ 18 | sdist/ 19 | var/ 20 | *.egg-info/ 21 | .installed.cfg 22 | *.egg 23 | 24 | # PyInstaller 25 | # Usually these files are written by a python script from a template 26 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 27 | *.manifest 28 | *.spec 29 | 30 | # Installer logs 31 | pip-log.txt 32 | pip-delete-this-directory.txt 33 | 34 | # Unit test / coverage reports 35 | htmlcov/ 36 | .tox/ 37 | .coverage 38 | .cache 39 | nosetests.xml 40 | coverage.xml 41 | 42 | # Translations 43 | *.mo 44 | *.pot 45 | 46 | # Django stuff: 47 | *.log 48 | 49 | # Sphinx documentation 50 | docs/_build/ 51 | 52 | # PyBuilder 53 | target/ 54 | 55 | gptools/kernel/_matern.c -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | install: 4 | - wget http://repo.continuum.io/miniconda/Miniconda-3.0.5-Linux-x86_64.sh 5 | - bash Miniconda-3.0.5-Linux-x86_64.sh -b 6 | - export PATH=$HOME/miniconda/bin:$PATH 7 | - conda install --yes -q numpy scipy matplotlib pip nose cython 8 | - pip install -q mpmath emcee triangle_plot # no conda packages :( 9 | - sudo rm -rf /dev/shm && sudo ln -s /run/shm /dev/shm 10 | 11 | script: 12 | - export CC="gcc -std=c89" 13 | - python setup.py install 14 | - cd tests 15 | - nosetests 16 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include README.rst 3 | include gptools/kernel/include/matern.h 4 | include gptools/kernel/src/matern.c 5 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | gptools 2 | ======= 3 | 4 | Gaussian processes with arbitrary derivative constraints and predictions. 5 | 6 | `gptools` is a Python package that provides a convenient, powerful and extensible implementation of Gaussian process regression (GPR). Central to `gptool`'s implementation is support for derivatives and their variances. Furthermore, the implementation supports the incorporation of arbitrary linearly transformed quantities into the GP. 7 | 8 | Developed and tested using Python 2.7 and scipy 0.14.0. May work with other versions, but it has not been tested under such configurations. 9 | 10 | Full package documentation is located at http://gptools.readthedocs.org/ 11 | 12 | A printable PDF is available at https://media.readthedocs.org/pdf/gptools/latest/gptools.pdf 13 | 14 | Releases are available in PyPI at https://pypi.python.org/pypi/gptools/ 15 | 16 | To install, simply execute:: 17 | 18 | pip install gptools 19 | 20 | (You must already have NumPy and Cython installed for this to work.) 21 | 22 | If you find this software useful, please be sure to cite it: 23 | 24 | M.A. Chilenski et al. 2015 Nucl. Fusion 55 023012 25 | 26 | http://stacks.iop.org/0029-5515/55/023012 27 | -------------------------------------------------------------------------------- /demo/sample_data_core.pkl: -------------------------------------------------------------------------------- 1 | (dp1 2 | S'y' 3 | cnumpy.core.multiarray 4 | _reconstruct 5 | p2 6 | (cnumpy 7 | ndarray 8 | p3 9 | (I0 10 | tS'b' 11 | tRp4 12 | (I1 13 | (I15 14 | tcnumpy 15 | dtype 16 | p5 17 | (S'f8' 18 | I0 19 | I1 20 | tRp6 21 | (I3 22 | S'<' 23 | NNNI-1 24 | I-1 25 | I0 26 | tbI00 27 | S'\xcd\xcc\xccL\xa6\x8c\x05@DDD4\x81=\x08@\x9a\x99\x99y\xe8\xa0\x05@DDD\x14\x7fQ\x06@"""\xf2\xa2\x96\x05@DDD$\x87\xd1\x05@fff&\x88\xd0\x02@\xbc\xbb\xbb\x0b\x9d1\x05@\xde\xdd\xdd\xed\xd2\x07\x02@www\xe7!\x0f\x03@ffff}J\x02@\xef\xee\xee\xce&\xfb\x03@\xab\xaa\xaaz\xc5R\x01@www\xa7\xb0\xcd\x00@\x11\x11\x11\x19\xa80\x01@' 28 | tbsS'X' 29 | g2 30 | (g3 31 | (I0 32 | tS'b' 33 | tRp7 34 | (I1 35 | (I15 36 | tg6 37 | I00 38 | S'\x06\xa63\xdf\x0c\xf8\xa5?p\xab\x9b\xf5\x14\xf9\xb3?\xdbN\x1c\x0b\xb3\x93\xcc?\x17\x00/^\xd7\x1e\xc8?\x04\x97d\x81"N\xd3?g\xddUv\x06\xf9\xd7?\xc0\xf5\xd1\xa3UO\xde?\xe4|d\xae\xa0\xcc\xda?\x9e\xf1\x08\xec5\xa2\xe2?\x1e\xe5x\xfan\x9f\xe0?[f\xbe\xb1t\xad\xe5?\xd6\xc0\xf1\xc9\xe8\xe4\xe3?\x87\xcf\x1aK\x15\xef\xe6?\x93C=bK\xcd\xe9?\xa5\x12\x9d\xa6&\x1d\xec?' 39 | tbsS'err_y' 40 | p8 41 | g2 42 | (g3 43 | (I0 44 | tS'b' 45 | tRp9 46 | (I1 47 | (I15 48 | tg6 49 | I00 50 | S'{Ey{\x13\x19\xbb?\xeb\xe3\x14w\xcbN\xbb?=\xd0d*-\xf2\xbe?\xaaL\xfa\xb2\x128\xbd?$XU\xb6\xdbB\xbc?\xb9\x11`|\x17\xb7\xb9?\x94\x10f\x17U)\xb5?\xc5\x1c\xcd;\x85z\xba?\xc7\xf9\x9b\xf54K\xb3?\x153\xd48\xb9\xec\xb4?\xba\x08\xcb\x9c\xc4\xb0\xbc?\x8e>\x1d\x8a\xf8\x84\xb8?\xa6\x04\xe6L\xe5\xa2\xb2??7\x05\xe9\xd9-\xba?"\xc7N\xa3F\xfd\xbb?' 51 | tbs. -------------------------------------------------------------------------------- /demo/sample_data_edge.pkl: -------------------------------------------------------------------------------- 1 | (dp1 2 | S'y' 3 | cnumpy.core.multiarray 4 | _reconstruct 5 | p2 6 | (cnumpy 7 | ndarray 8 | p3 9 | (I0 10 | tS'b' 11 | tRp4 12 | (I1 13 | (I18 14 | tcnumpy 15 | dtype 16 | p5 17 | (S'f8' 18 | I0 19 | I1 20 | tRp6 21 | (I3 22 | S'<' 23 | NNNI-1 24 | I-1 25 | I0 26 | tbI00 27 | S"\xbc\xbb\xbb\xab0'\xff?www\x07\x8at\xfd?333S\xe9\x14\xfc?\xab\xaa\xaa\xca\x9b)\xfd?\x9a\x99\x99\xa9h<\xfa?\xcd\xcc\xcc\x9c%\x8a\xf9?\xde\xdd\xdd]\x1a-\xf9?DDDl\xdc\x19\xf6?333{\x0fg\xef?\xab\xaa\xaazG^\xe5?\t\xcb=M\xb1\xde\xe0?\x89\x88\x88\xc8Z\x04\xe0?%I\x92h\x81/\xe1?\x9e\xd8\x89iv\xc8\xd7?j\x84\xe5\xfe\x02M\xe0?vb'\x9a=\xb2\xdc?\xb2\x90\x85D\x91\xeb\xd6?\xc5N\xec$\x06\x11\xdd?" 28 | tbsS'X' 29 | g2 30 | (g3 31 | (I0 32 | tS'b' 33 | tRp7 34 | (I1 35 | (I18 36 | tg6 37 | I00 38 | S'\xfcZ\x8f\x14\xbd$\xed?\xa7\x9a\t\xaeY\xc2\xed?nII\xe8\xfaY\xee?\x07P\xa0Sm.\xef?\xc2\xd7<~Xs\xef? \xe3u\x87V\xb3\xef?\x02\x8e\xde\xe8]\xf8\xef?\xc1\xcb\xd7\xe3\xa1\x1a\xf0?\x1f\x9a+Vz-\xf0?\x05\x9f\x04\xb2\x8dA\xf0?.\x8c\xf2\x81xS\xf0?\x916xO\xade\xf0?\xa1\xc065\rx\xf0?@B\xa1\x16;\x89\xf0?p\x14\x13\x0f\x03\x9b\xf0?\x13\x8b\x8a\xc4\xf8\xab\xf0?*\x8aO\xd5x\xcc\xf0?\xb1\xbf[\xb1L\xea\xf0?' 39 | tbsS'err_y' 40 | p8 41 | g2 42 | (g3 43 | (I0 44 | tS'b' 45 | tRp9 46 | (I1 47 | (I18 48 | tg6 49 | I00 50 | S'2\xba\xfc\x90K\xf1\xc4?\nt\x0e\x98\xac\x97\xc2?\xae\xcf\x9a\xd8\xc8Z\xc0?\xf2R\xb4\x83c\x95\xbf?&]q\xaa\xc4\xb2\xc3?N\x8e#4\x96\x87\xc1?\x11\xbdt\xd2\xaa\x8b\xc8?\xf2\xd8\xc1\xf6\xbd\x0b\xd5?\xd1k\xfd\xeb\x94X\xd6?\xebckK\xf0\xd5\xc7?\n\r\xee\x1e#<\xc5?\x9bV%\xaf\x12\x08\xc6?\xe8c\r\xfd\x90\x82\xca?\x1a\x93K\xe2\x04\xa4\xc4?I\xeb\x11\xfeA,\xcf?\xa0u\xb4|\x0b~\xc9?\xf4\x19\xb6\x08\x9f\x12\xc3?\x06\x89\xd0b\x9e\xc6\xcb?' 51 | tbs. -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | 41 | clean: 42 | -rm -rf $(BUILDDIR)/* 43 | 44 | html: 45 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 48 | 49 | dirhtml: 50 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 51 | @echo 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 53 | 54 | singlehtml: 55 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 56 | @echo 57 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 58 | 59 | pickle: 60 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 61 | @echo 62 | @echo "Build finished; now you can process the pickle files." 63 | 64 | json: 65 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 66 | @echo 67 | @echo "Build finished; now you can process the JSON files." 68 | 69 | htmlhelp: 70 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 71 | @echo 72 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 73 | ".hhp project file in $(BUILDDIR)/htmlhelp." 74 | 75 | qthelp: 76 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 77 | @echo 78 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 79 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 80 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/gptools.qhcp" 81 | @echo "To view the help file:" 82 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/gptools.qhc" 83 | 84 | devhelp: 85 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 86 | @echo 87 | @echo "Build finished." 88 | @echo "To view the help file:" 89 | @echo "# mkdir -p $$HOME/.local/share/devhelp/gptools" 90 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/gptools" 91 | @echo "# devhelp" 92 | 93 | epub: 94 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 95 | @echo 96 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 97 | 98 | latex: 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 107 | @echo "Running LaTeX files through pdflatex..." 108 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 109 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 110 | 111 | text: 112 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 113 | @echo 114 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 115 | 116 | man: 117 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 118 | @echo 119 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 120 | 121 | texinfo: 122 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 123 | @echo 124 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 125 | @echo "Run \`make' in that directory to run these through makeinfo" \ 126 | "(use \`make info' here to do that automatically)." 127 | 128 | info: 129 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 130 | @echo "Running Texinfo files through makeinfo..." 131 | make -C $(BUILDDIR)/texinfo info 132 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 133 | 134 | gettext: 135 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 136 | @echo 137 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 138 | 139 | changes: 140 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 141 | @echo 142 | @echo "The overview file is in $(BUILDDIR)/changes." 143 | 144 | linkcheck: 145 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 146 | @echo 147 | @echo "Link check complete; look for any errors in the above output " \ 148 | "or in $(BUILDDIR)/linkcheck/output.txt." 149 | 150 | doctest: 151 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 152 | @echo "Testing of doctests in the sources finished, look at the " \ 153 | "results in $(BUILDDIR)/doctest/output.txt." 154 | -------------------------------------------------------------------------------- /docs/build/doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/doctrees/environment.pickle -------------------------------------------------------------------------------- /docs/build/doctrees/gptools.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/doctrees/gptools.doctree -------------------------------------------------------------------------------- /docs/build/doctrees/gptools.kernel.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/doctrees/gptools.kernel.doctree -------------------------------------------------------------------------------- /docs/build/doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/doctrees/index.doctree -------------------------------------------------------------------------------- /docs/build/doctrees/modules.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/doctrees/modules.doctree -------------------------------------------------------------------------------- /docs/build/html/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 660eafa54e574cf05f70c5c2388f4453 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /docs/build/html/_images/math/0024155eabfcd1190d07f9520b42da07cc573f98.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/0024155eabfcd1190d07f9520b42da07cc573f98.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/15c0e5b01b2bdc6a5ed2eea279f4c2f2b7cfd70b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/15c0e5b01b2bdc6a5ed2eea279f4c2f2b7cfd70b.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/172e6dadffd9800e796f3f96a1e24ce2a1840f3a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/172e6dadffd9800e796f3f96a1e24ce2a1840f3a.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/2be7268c95610c46b5939dc92d48f8a5eea456ab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/2be7268c95610c46b5939dc92d48f8a5eea456ab.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/3e4706baa604e1794d41d43400ba7708395a055b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/3e4706baa604e1794d41d43400ba7708395a055b.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/3f243899bc87ead4773f775f234b52af69f27836.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/3f243899bc87ead4773f775f234b52af69f27836.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/57a710d686452bd0ecc177300d3e523c300445a3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/57a710d686452bd0ecc177300d3e523c300445a3.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/57ff4ac903860e9b65cecd0a4d38e725be98ec86.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/57ff4ac903860e9b65cecd0a4d38e725be98ec86.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/5e1668792d162faf7f4c6f233fcf3fda1b4f8592.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/5e1668792d162faf7f4c6f233fcf3fda1b4f8592.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/6555583597f0140ab50c633f415f7b24ae12ce8d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/6555583597f0140ab50c633f415f7b24ae12ce8d.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/7198c11f22989d15f71fc60acc87c66017ea5e94.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/7198c11f22989d15f71fc60acc87c66017ea5e94.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/897470a282b6b85fa5221eacd41369b9a157f491.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/897470a282b6b85fa5221eacd41369b9a157f491.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/9ad99798ec4c38e165cf517cb9e02b1c9e824103.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/9ad99798ec4c38e165cf517cb9e02b1c9e824103.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/9c8517c8f741ce57640333495649385dd9f0c8cc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/9c8517c8f741ce57640333495649385dd9f0c8cc.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/a6b81ac9039f9854754a5a0ccb8f93d66b4e3fec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/a6b81ac9039f9854754a5a0ccb8f93d66b4e3fec.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/afed7b6656e31605fbc89857f1260a9e62dda899.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/afed7b6656e31605fbc89857f1260a9e62dda899.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/b339c4c45440f4de3adc6c7b8f87571841bed3c0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/b339c4c45440f4de3adc6c7b8f87571841bed3c0.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/c440ab49d1eecb2a30a497bb59468065541125f8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/c440ab49d1eecb2a30a497bb59468065541125f8.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/ce3fbc71c8696e043988d37d4140479fa0b6940b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/ce3fbc71c8696e043988d37d4140479fa0b6940b.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/d6a7ccf879c4a4fe694033606332cb83806db296.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/d6a7ccf879c4a4fe694033606332cb83806db296.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/d988f25fabbe6e8d7295e0b08ae4a3c48a89004e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/d988f25fabbe6e8d7295e0b08ae4a3c48a89004e.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/e186cdff23ad92dbe25521fcb875ef7618df6284.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/e186cdff23ad92dbe25521fcb875ef7618df6284.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/f49377a915206cf8e5956a4c388e1ca70c048f57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/f49377a915206cf8e5956a4c388e1ca70c048f57.png -------------------------------------------------------------------------------- /docs/build/html/_images/math/fb8eb09dd92824edc267624b0de1ed9eb5431d77.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_images/math/fb8eb09dd92824edc267624b0de1ed9eb5431d77.png -------------------------------------------------------------------------------- /docs/build/html/_modules/gptools/error_handling.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | gptools.error_handling — gptools 0.2 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 46 | 47 |
48 |
49 |
50 |
51 | 52 |

Source code for gptools.error_handling

 53 | # Copyright 2014 Mark Chilenski
 54 | # This program is distributed under the terms of the GNU General Purpose License (GPL).
 55 | # Refer to http://www.gnu.org/licenses/gpl.txt
 56 | # 
 57 | # This program is free software: you can redistribute it and/or modify
 58 | # it under the terms of the GNU General Public License as published by
 59 | # the Free Software Foundation, either version 3 of the License, or
 60 | # (at your option) any later version.
 61 | # 
 62 | # This program is distributed in the hope that it will be useful,
 63 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
 64 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 65 | # GNU General Public License for more details.
 66 | # 
 67 | # You should have received a copy of the GNU General Public License
 68 | # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 69 | 
 70 | """Contains exceptions specific to the :py:mod:`gptools` package.
 71 | """
 72 | 
 73 | from __future__ import division
 74 | 
 75 | 
[docs]class GPArgumentError(Exception): 76 | """Exception class raised when an incorrect combination of keyword arguments is given. 77 | """ 78 | pass
79 |
80 | 81 |
82 |
83 |
84 |
85 |
86 | 98 | 99 |
100 |
101 |
102 |
103 | 119 | 123 | 124 | -------------------------------------------------------------------------------- /docs/build/html/_modules/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Overview: module code — gptools 0.2 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 44 | 45 |
46 | 68 |
69 |
70 | 82 | 83 |
84 |
85 |
86 |
87 | 102 | 106 | 107 | -------------------------------------------------------------------------------- /docs/build/html/_sources/gptools.kernel.txt: -------------------------------------------------------------------------------- 1 | gptools.kernel package 2 | ====================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | gptools.kernel.core module 8 | -------------------------- 9 | 10 | .. automodule:: gptools.kernel.core 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | gptools.kernel.gibbs module 16 | --------------------------- 17 | 18 | .. automodule:: gptools.kernel.gibbs 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | gptools.kernel.matern module 24 | ---------------------------- 25 | 26 | .. automodule:: gptools.kernel.matern 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | gptools.kernel.noise module 32 | --------------------------- 33 | 34 | .. automodule:: gptools.kernel.noise 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | gptools.kernel.rational_quadratic module 40 | ---------------------------------------- 41 | 42 | .. automodule:: gptools.kernel.rational_quadratic 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | 47 | gptools.kernel.squared_exponential module 48 | ----------------------------------------- 49 | 50 | .. automodule:: gptools.kernel.squared_exponential 51 | :members: 52 | :undoc-members: 53 | :show-inheritance: 54 | 55 | gptools.kernel.warping module 56 | ----------------------------- 57 | 58 | .. automodule:: gptools.kernel.warping 59 | :members: 60 | :undoc-members: 61 | :show-inheritance: 62 | 63 | 64 | Module contents 65 | --------------- 66 | 67 | .. automodule:: gptools.kernel 68 | :members: 69 | :undoc-members: 70 | :show-inheritance: 71 | -------------------------------------------------------------------------------- /docs/build/html/_sources/gptools.txt: -------------------------------------------------------------------------------- 1 | gptools package 2 | =============== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | 9 | gptools.kernel 10 | 11 | Submodules 12 | ---------- 13 | 14 | gptools.error_handling module 15 | ----------------------------- 16 | 17 | .. automodule:: gptools.error_handling 18 | :members: 19 | :undoc-members: 20 | :show-inheritance: 21 | 22 | gptools.gaussian_process module 23 | ------------------------------- 24 | 25 | .. automodule:: gptools.gaussian_process 26 | :members: 27 | :undoc-members: 28 | :show-inheritance: 29 | 30 | gptools.gp_utils module 31 | ----------------------- 32 | 33 | .. automodule:: gptools.gp_utils 34 | :members: 35 | :undoc-members: 36 | :show-inheritance: 37 | 38 | gptools.mean module 39 | ------------------- 40 | 41 | .. automodule:: gptools.mean 42 | :members: 43 | :undoc-members: 44 | :show-inheritance: 45 | 46 | gptools.utils module 47 | -------------------- 48 | 49 | .. automodule:: gptools.utils 50 | :members: 51 | :undoc-members: 52 | :show-inheritance: 53 | 54 | 55 | Module contents 56 | --------------- 57 | 58 | .. automodule:: gptools 59 | :members: 60 | :undoc-members: 61 | :show-inheritance: 62 | -------------------------------------------------------------------------------- /docs/build/html/_sources/index.txt: -------------------------------------------------------------------------------- 1 | .. gptools documentation master file, created by 2 | sphinx-quickstart on Tue Sep 3 12:06:03 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | gptools: Gaussian process regression with support for arbitrary derivatives 7 | =========================================================================== 8 | 9 | Source home: https://github.com/markchil/gptools 10 | 11 | Releases: https://pypi.python.org/pypi/gptools/ 12 | 13 | Installation is as simple as:: 14 | 15 | pip install gptools 16 | 17 | Overview 18 | -------- 19 | 20 | :py:mod:`gptools` is a Python package that provides a convenient, powerful and extensible implementation of Gaussian process regression (GPR). Central to :py:mod:`gptool`'s implementation is support for derivatives and their variances. Furthermore, the implementation supports the incorporation of arbitrary linearly transformed quantities into the GP. 21 | 22 | There are two key classes: 23 | 24 | * :py:class:`~gptools.gaussian_process.GaussianProcess` is the main class to represent a GP. 25 | * :py:class:`~gptools.kernel.core.Kernel` (and its many subclasses) represents a covariance kernel, and must be provided when constructing a :py:class:`~gptools.gaussian_process.GaussianProcess`. Separate kernels to describe the underlying signal and the noise are supported. 26 | 27 | A third class, :py:class:`~gptools.utils.JointPrior`, allows you to construct a hyperprior of arbitrary complexity to dictate how the hyperparameters are handled. 28 | 29 | Creating a Gaussian process is as simple as:: 30 | 31 | import gptools 32 | k = gptools.SquaredExponentialKernel() 33 | gp = gptools.GaussianProcess(k) 34 | 35 | But, the default bounds on the hyperparameters are very wide and can cause the optimizer/MCMC sampler to fail. So, it is usually a better idea to define the covariance kernel as:: 36 | 37 | k = gptools.SquaredExponentialKernel(param_bounds=[(0, 1e3), (0, 100)]) 38 | 39 | You will have to pick appropriate numbers by inspecting the typical range of your data. 40 | 41 | Furthermore, you can include an explicit mean function by passing 42 | the appropriate :py:class:`~gptools.mean.MeanFunction` instance into the `mu` keyword:: 43 | 44 | gp = gptools.GaussianProcess(k, mu=gptools.LinearMeanFunction()) 45 | 46 | This will enable you to perform inference (both empirical and full Bayes) for 47 | the hyperparameters of the mean function. Essentially, :py:mod:`gptools` can 48 | perform nonlinear Bayesian regression with a Gaussian process fit to the 49 | residuals. 50 | 51 | You then add the training data using the :py:meth:`~gptools.gaussian_process.GaussianProcess.add_data` method:: 52 | 53 | gp.add_data(x, y, err_y=stddev_y) 54 | 55 | Here, `err_y` is the :math:`1\sigma` uncertainty on the observations `y`. For exact values, simply omit this keyword. Adding a derivative observation is as simple as specifying the derivative order with the `n` keyword:: 56 | 57 | gp.add_data(0, 0, n=1) 58 | 59 | This will force the slope at :math:`x=0` to be exactly zero. Quantities that represent an arbitrary linear transformation of the "basic" observations can be added by specifying the `T` keyword:: 60 | 61 | gp.add_data(x, y, T=T) 62 | 63 | This will add the value(s) :math:`y = T Y(x)` to the training data, where here :math:`Y` represents the "basic" (untransformed) observations and :math:`y` represents the transformed observations. This also supports the `err_y` and `n` keywords. Here, `err_y` is the error on the transformed quantity :math:`y`. `n` applies to the latent variables :math:`Y(x)`. 64 | 65 | Once the GP has been populated with training data, there are two approaches supported to handle the hyperparameters. 66 | 67 | The simplest approach is to use an empirical Bayes approach and compute the maximum a posteriori (MAP) estimate. This is accomplished using the :py:meth:`~gptools.gaussian_process.GaussianProcess.optimize_hyperparameters` method of the :py:class:`~gptools.gaussian_process.GaussianProcess` instance:: 68 | 69 | gp.optimize_hyperparameters() 70 | 71 | This will randomly start the optimizer at points distributed according to the hyperprior several times in order to ensure that the global maximum is obtained. If you have a machine with multiple cores, these random starts will be performed in parallel. You can set the number of starts using the `random_starts` keyword, and you can set the number of processes used using the `num_proc` keyword. 72 | 73 | For a more complete accounting of the uncertainties in the model, you can choose to use a fully Bayesian approach by using Markov chain Monte Carlo (MCMC) techniques to produce samples of the hyperposterior. The samples are produced directly with :py:meth:`~gptools.gaussian_process.GaussianProcess.sample_hyperparameter_posterior`, though it will typically be more convenient to simply call :py:meth:`~gptools.gaussian_process.GaussianProcess.predict` with the `use_MCMC` keyword set to True. 74 | 75 | In order to make predictions, use the :py:meth:`~gptools.gaussian_process.GaussianProcess.predict` method:: 76 | 77 | y_star, err_y_star = gp.predict(x_star) 78 | 79 | By default, the mean and standard deviation of the GP posterior are returned. To compute only the mean and save some time, set the `return_std` keyword to False. To make predictions of derivatives, set the `n` keyword. To make a prediction of a linearly transformed quantity, set the `output_transform` keyword. 80 | 81 | For a convenient wrapper for applying :py:mod:`gptools` to multivariate data, see :py:mod:`profiletools` at https://github.com/markchil/profiletools 82 | 83 | Kernels 84 | ------- 85 | 86 | A number of kernels are provided to allow many types of data to be fit: 87 | 88 | * :py:class:`~gptools.kernel.noise.DiagonalNoiseKernel` implements homoscedastic noise. The noise is tied to a specific derivative order. This allows you to, for instance, have noise on your observations but have noiseless derivative constraints, or to have different noise levels for observations and derivatives. Note that you can also specify potentially heteroscedastic noise explicitly when adding data to the process. 89 | * :py:class:`~gptools.kernel.squared_exponential.SquaredExponentialKernel` implements the SE kernel which is infinitely differentiable. 90 | * :py:class:`~gptools.kernel.matern.MaternKernel` implements the entire Matern class of covariance functions, which are characterized by a hyperparameter :math:`\nu`. A process having the Matern kernel is only mean-square differentiable for derivative order :math:`n<\nu`. Note that this class does not support arbitrary derivatives at this point. If you need this feature, try using :py:class:`~gptools.kernel.matern.MaternKernelArb`, but note that this is very slow! 91 | * :py:class:`~gptools.kernel.matern.Matern52Kernel` implements a specialized Matern kernel with :math:`\nu=\frac{5}{2}` which efficiently supports 0th and 1st derivatives. 92 | * :py:class:`~gptools.kernel.rational_quadratic.RationalQuadraticKernel` implements the rational quadratic kernel, which is a scale mixture over SE kernels. 93 | * :py:class:`~gptools.kernel.gibbs.GibbsKernel1d` and its subclasses implements the Gibbs kernel, which is a nonstationary form of the SE kernel. 94 | * :py:class:`~gptools.kernel.core.MaskedKernel` creates a kernel that only operates on a subset of dimensions. Use this along with the sum and product operations to create kernels that encode different properties in different dimensions. 95 | * :py:class:`~gptools.kernel.core.ArbitraryKernel` creates a kernel with an arbitrary covariance function and computes the derivatives as needed using :py:mod:`mpmath` to perform numerical differentiation. Naturally, this is very slow but is useful to let you explore the properties of arbitrary kernels without having to write a complete implementation. 96 | 97 | In most cases, these kernels have been constructed in a way to allow inputs of arbitrary dimension. Each dimension has a length scale hyperparameter that can be separately optimized over or held fixed. Arbitrary derivatives with respect to each dimension can be taken, including computation of the covariance for those observations. 98 | 99 | Other kernels can be implemented by extending the :py:class:`~gptools.kernel.core.Kernel` class. Furthermore, kernels may be added or multiplied together to yield a new, valid kernel. 100 | 101 | Notes 102 | ----- 103 | 104 | :py:mod:`gptools` has been developed and tested on Python 2.7 and scipy 0.14.0. It may work just as well on other versions, but has not been tested. 105 | 106 | If you find this software useful, please be sure to cite it: 107 | 108 | M.A. Chilenski (2014). gptools: Gaussian processes with arbitrary derivative constraints and predictions, GNU General Public License. github.com/markchil/gptools 109 | 110 | A formal publication on this software and its applications is in preparation. Once this is published, this readme will be updated with the relevant citation. 111 | 112 | Contents 113 | -------- 114 | 115 | .. toctree:: 116 | :maxdepth: 4 117 | 118 | gptools 119 | 120 | Indices and tables 121 | ================== 122 | 123 | * :ref:`genindex` 124 | * :ref:`modindex` 125 | * :ref:`search` 126 | 127 | -------------------------------------------------------------------------------- /docs/build/html/_sources/modules.txt: -------------------------------------------------------------------------------- 1 | gptools 2 | ======= 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | gptools 8 | -------------------------------------------------------------------------------- /docs/build/html/_static/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/ajax-loader.gif -------------------------------------------------------------------------------- /docs/build/html/_static/basic.css: -------------------------------------------------------------------------------- 1 | /* 2 | * basic.css 3 | * ~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- basic theme. 6 | * 7 | * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /* -- main layout ----------------------------------------------------------- */ 13 | 14 | div.clearer { 15 | clear: both; 16 | } 17 | 18 | /* -- relbar ---------------------------------------------------------------- */ 19 | 20 | div.related { 21 | width: 100%; 22 | font-size: 90%; 23 | } 24 | 25 | div.related h3 { 26 | display: none; 27 | } 28 | 29 | div.related ul { 30 | margin: 0; 31 | padding: 0 0 0 10px; 32 | list-style: none; 33 | } 34 | 35 | div.related li { 36 | display: inline; 37 | } 38 | 39 | div.related li.right { 40 | float: right; 41 | margin-right: 5px; 42 | } 43 | 44 | /* -- sidebar --------------------------------------------------------------- */ 45 | 46 | div.sphinxsidebarwrapper { 47 | padding: 10px 5px 0 10px; 48 | } 49 | 50 | div.sphinxsidebar { 51 | float: left; 52 | width: 230px; 53 | margin-left: -100%; 54 | font-size: 90%; 55 | } 56 | 57 | div.sphinxsidebar ul { 58 | list-style: none; 59 | } 60 | 61 | div.sphinxsidebar ul ul, 62 | div.sphinxsidebar ul.want-points { 63 | margin-left: 20px; 64 | list-style: square; 65 | } 66 | 67 | div.sphinxsidebar ul ul { 68 | margin-top: 0; 69 | margin-bottom: 0; 70 | } 71 | 72 | div.sphinxsidebar form { 73 | margin-top: 10px; 74 | } 75 | 76 | div.sphinxsidebar input { 77 | border: 1px solid #98dbcc; 78 | font-family: sans-serif; 79 | font-size: 1em; 80 | } 81 | 82 | div.sphinxsidebar #searchbox input[type="text"] { 83 | width: 170px; 84 | } 85 | 86 | div.sphinxsidebar #searchbox input[type="submit"] { 87 | width: 30px; 88 | } 89 | 90 | img { 91 | border: 0; 92 | max-width: 100%; 93 | } 94 | 95 | /* -- search page ----------------------------------------------------------- */ 96 | 97 | ul.search { 98 | margin: 10px 0 0 20px; 99 | padding: 0; 100 | } 101 | 102 | ul.search li { 103 | padding: 5px 0 5px 20px; 104 | background-image: url(file.png); 105 | background-repeat: no-repeat; 106 | background-position: 0 7px; 107 | } 108 | 109 | ul.search li a { 110 | font-weight: bold; 111 | } 112 | 113 | ul.search li div.context { 114 | color: #888; 115 | margin: 2px 0 0 30px; 116 | text-align: left; 117 | } 118 | 119 | ul.keywordmatches li.goodmatch a { 120 | font-weight: bold; 121 | } 122 | 123 | /* -- index page ------------------------------------------------------------ */ 124 | 125 | table.contentstable { 126 | width: 90%; 127 | } 128 | 129 | table.contentstable p.biglink { 130 | line-height: 150%; 131 | } 132 | 133 | a.biglink { 134 | font-size: 1.3em; 135 | } 136 | 137 | span.linkdescr { 138 | font-style: italic; 139 | padding-top: 5px; 140 | font-size: 90%; 141 | } 142 | 143 | /* -- general index --------------------------------------------------------- */ 144 | 145 | table.indextable { 146 | width: 100%; 147 | } 148 | 149 | table.indextable td { 150 | text-align: left; 151 | vertical-align: top; 152 | } 153 | 154 | table.indextable dl, table.indextable dd { 155 | margin-top: 0; 156 | margin-bottom: 0; 157 | } 158 | 159 | table.indextable tr.pcap { 160 | height: 10px; 161 | } 162 | 163 | table.indextable tr.cap { 164 | margin-top: 10px; 165 | background-color: #f2f2f2; 166 | } 167 | 168 | img.toggler { 169 | margin-right: 3px; 170 | margin-top: 3px; 171 | cursor: pointer; 172 | } 173 | 174 | div.modindex-jumpbox { 175 | border-top: 1px solid #ddd; 176 | border-bottom: 1px solid #ddd; 177 | margin: 1em 0 1em 0; 178 | padding: 0.4em; 179 | } 180 | 181 | div.genindex-jumpbox { 182 | border-top: 1px solid #ddd; 183 | border-bottom: 1px solid #ddd; 184 | margin: 1em 0 1em 0; 185 | padding: 0.4em; 186 | } 187 | 188 | /* -- general body styles --------------------------------------------------- */ 189 | 190 | a.headerlink { 191 | visibility: hidden; 192 | } 193 | 194 | h1:hover > a.headerlink, 195 | h2:hover > a.headerlink, 196 | h3:hover > a.headerlink, 197 | h4:hover > a.headerlink, 198 | h5:hover > a.headerlink, 199 | h6:hover > a.headerlink, 200 | dt:hover > a.headerlink { 201 | visibility: visible; 202 | } 203 | 204 | div.body p.caption { 205 | text-align: inherit; 206 | } 207 | 208 | div.body td { 209 | text-align: left; 210 | } 211 | 212 | .field-list ul { 213 | padding-left: 1em; 214 | } 215 | 216 | .first { 217 | margin-top: 0 !important; 218 | } 219 | 220 | p.rubric { 221 | margin-top: 30px; 222 | font-weight: bold; 223 | } 224 | 225 | img.align-left, .figure.align-left, object.align-left { 226 | clear: left; 227 | float: left; 228 | margin-right: 1em; 229 | } 230 | 231 | img.align-right, .figure.align-right, object.align-right { 232 | clear: right; 233 | float: right; 234 | margin-left: 1em; 235 | } 236 | 237 | img.align-center, .figure.align-center, object.align-center { 238 | display: block; 239 | margin-left: auto; 240 | margin-right: auto; 241 | } 242 | 243 | .align-left { 244 | text-align: left; 245 | } 246 | 247 | .align-center { 248 | text-align: center; 249 | } 250 | 251 | .align-right { 252 | text-align: right; 253 | } 254 | 255 | /* -- sidebars -------------------------------------------------------------- */ 256 | 257 | div.sidebar { 258 | margin: 0 0 0.5em 1em; 259 | border: 1px solid #ddb; 260 | padding: 7px 7px 0 7px; 261 | background-color: #ffe; 262 | width: 40%; 263 | float: right; 264 | } 265 | 266 | p.sidebar-title { 267 | font-weight: bold; 268 | } 269 | 270 | /* -- topics ---------------------------------------------------------------- */ 271 | 272 | div.topic { 273 | border: 1px solid #ccc; 274 | padding: 7px 7px 0 7px; 275 | margin: 10px 0 10px 0; 276 | } 277 | 278 | p.topic-title { 279 | font-size: 1.1em; 280 | font-weight: bold; 281 | margin-top: 10px; 282 | } 283 | 284 | /* -- admonitions ----------------------------------------------------------- */ 285 | 286 | div.admonition { 287 | margin-top: 10px; 288 | margin-bottom: 10px; 289 | padding: 7px; 290 | } 291 | 292 | div.admonition dt { 293 | font-weight: bold; 294 | } 295 | 296 | div.admonition dl { 297 | margin-bottom: 0; 298 | } 299 | 300 | p.admonition-title { 301 | margin: 0px 10px 5px 0px; 302 | font-weight: bold; 303 | } 304 | 305 | div.body p.centered { 306 | text-align: center; 307 | margin-top: 25px; 308 | } 309 | 310 | /* -- tables ---------------------------------------------------------------- */ 311 | 312 | table.docutils { 313 | border: 0; 314 | border-collapse: collapse; 315 | } 316 | 317 | table.docutils td, table.docutils th { 318 | padding: 1px 8px 1px 5px; 319 | border-top: 0; 320 | border-left: 0; 321 | border-right: 0; 322 | border-bottom: 1px solid #aaa; 323 | } 324 | 325 | table.field-list td, table.field-list th { 326 | border: 0 !important; 327 | } 328 | 329 | table.footnote td, table.footnote th { 330 | border: 0 !important; 331 | } 332 | 333 | th { 334 | text-align: left; 335 | padding-right: 5px; 336 | } 337 | 338 | table.citation { 339 | border-left: solid 1px gray; 340 | margin-left: 1px; 341 | } 342 | 343 | table.citation td { 344 | border-bottom: none; 345 | } 346 | 347 | /* -- other body styles ----------------------------------------------------- */ 348 | 349 | ol.arabic { 350 | list-style: decimal; 351 | } 352 | 353 | ol.loweralpha { 354 | list-style: lower-alpha; 355 | } 356 | 357 | ol.upperalpha { 358 | list-style: upper-alpha; 359 | } 360 | 361 | ol.lowerroman { 362 | list-style: lower-roman; 363 | } 364 | 365 | ol.upperroman { 366 | list-style: upper-roman; 367 | } 368 | 369 | dl { 370 | margin-bottom: 15px; 371 | } 372 | 373 | dd p { 374 | margin-top: 0px; 375 | } 376 | 377 | dd ul, dd table { 378 | margin-bottom: 10px; 379 | } 380 | 381 | dd { 382 | margin-top: 3px; 383 | margin-bottom: 10px; 384 | margin-left: 30px; 385 | } 386 | 387 | dt:target, .highlighted { 388 | background-color: #fbe54e; 389 | } 390 | 391 | dl.glossary dt { 392 | font-weight: bold; 393 | font-size: 1.1em; 394 | } 395 | 396 | .field-list ul { 397 | margin: 0; 398 | padding-left: 1em; 399 | } 400 | 401 | .field-list p { 402 | margin: 0; 403 | } 404 | 405 | .optional { 406 | font-size: 1.3em; 407 | } 408 | 409 | .versionmodified { 410 | font-style: italic; 411 | } 412 | 413 | .system-message { 414 | background-color: #fda; 415 | padding: 5px; 416 | border: 3px solid red; 417 | } 418 | 419 | .footnote:target { 420 | background-color: #ffa; 421 | } 422 | 423 | .line-block { 424 | display: block; 425 | margin-top: 1em; 426 | margin-bottom: 1em; 427 | } 428 | 429 | .line-block .line-block { 430 | margin-top: 0; 431 | margin-bottom: 0; 432 | margin-left: 1.5em; 433 | } 434 | 435 | .guilabel, .menuselection { 436 | font-family: sans-serif; 437 | } 438 | 439 | .accelerator { 440 | text-decoration: underline; 441 | } 442 | 443 | .classifier { 444 | font-style: oblique; 445 | } 446 | 447 | abbr, acronym { 448 | border-bottom: dotted 1px; 449 | cursor: help; 450 | } 451 | 452 | /* -- code displays --------------------------------------------------------- */ 453 | 454 | pre { 455 | overflow: auto; 456 | overflow-y: hidden; /* fixes display issues on Chrome browsers */ 457 | } 458 | 459 | td.linenos pre { 460 | padding: 5px 0px; 461 | border: 0; 462 | background-color: transparent; 463 | color: #aaa; 464 | } 465 | 466 | table.highlighttable { 467 | margin-left: 0.5em; 468 | } 469 | 470 | table.highlighttable td { 471 | padding: 0 0.5em 0 0.5em; 472 | } 473 | 474 | tt.descname { 475 | background-color: transparent; 476 | font-weight: bold; 477 | font-size: 1.2em; 478 | } 479 | 480 | tt.descclassname { 481 | background-color: transparent; 482 | } 483 | 484 | tt.xref, a tt { 485 | background-color: transparent; 486 | font-weight: bold; 487 | } 488 | 489 | h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { 490 | background-color: transparent; 491 | } 492 | 493 | .viewcode-link { 494 | float: right; 495 | } 496 | 497 | .viewcode-back { 498 | float: right; 499 | font-family: sans-serif; 500 | } 501 | 502 | div.viewcode-block:target { 503 | margin: -1px -10px; 504 | padding: 0 10px; 505 | } 506 | 507 | /* -- math display ---------------------------------------------------------- */ 508 | 509 | img.math { 510 | vertical-align: middle; 511 | } 512 | 513 | div.body div.math p { 514 | text-align: center; 515 | } 516 | 517 | span.eqno { 518 | float: right; 519 | } 520 | 521 | /* -- printout stylesheet --------------------------------------------------- */ 522 | 523 | @media print { 524 | div.document, 525 | div.documentwrapper, 526 | div.bodywrapper { 527 | margin: 0 !important; 528 | width: 100%; 529 | } 530 | 531 | div.sphinxsidebar, 532 | div.related, 533 | div.footer, 534 | #top-link { 535 | display: none; 536 | } 537 | } -------------------------------------------------------------------------------- /docs/build/html/_static/comment-bright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/comment-bright.png -------------------------------------------------------------------------------- /docs/build/html/_static/comment-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/comment-close.png -------------------------------------------------------------------------------- /docs/build/html/_static/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/comment.png -------------------------------------------------------------------------------- /docs/build/html/_static/default.css: -------------------------------------------------------------------------------- 1 | /* 2 | * default.css_t 3 | * ~~~~~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- default theme. 6 | * 7 | * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | @import url("basic.css"); 13 | 14 | /* -- page layout ----------------------------------------------------------- */ 15 | 16 | body { 17 | font-family: sans-serif; 18 | font-size: 100%; 19 | background-color: #11303d; 20 | color: #000; 21 | margin: 0; 22 | padding: 0; 23 | } 24 | 25 | div.document { 26 | background-color: #1c4e63; 27 | } 28 | 29 | div.documentwrapper { 30 | float: left; 31 | width: 100%; 32 | } 33 | 34 | div.bodywrapper { 35 | margin: 0 0 0 230px; 36 | } 37 | 38 | div.body { 39 | background-color: #ffffff; 40 | color: #000000; 41 | padding: 0 20px 30px 20px; 42 | } 43 | 44 | div.footer { 45 | color: #ffffff; 46 | width: 100%; 47 | padding: 9px 0 9px 0; 48 | text-align: center; 49 | font-size: 75%; 50 | } 51 | 52 | div.footer a { 53 | color: #ffffff; 54 | text-decoration: underline; 55 | } 56 | 57 | div.related { 58 | background-color: #133f52; 59 | line-height: 30px; 60 | color: #ffffff; 61 | } 62 | 63 | div.related a { 64 | color: #ffffff; 65 | } 66 | 67 | div.sphinxsidebar { 68 | } 69 | 70 | div.sphinxsidebar h3 { 71 | font-family: 'Trebuchet MS', sans-serif; 72 | color: #ffffff; 73 | font-size: 1.4em; 74 | font-weight: normal; 75 | margin: 0; 76 | padding: 0; 77 | } 78 | 79 | div.sphinxsidebar h3 a { 80 | color: #ffffff; 81 | } 82 | 83 | div.sphinxsidebar h4 { 84 | font-family: 'Trebuchet MS', sans-serif; 85 | color: #ffffff; 86 | font-size: 1.3em; 87 | font-weight: normal; 88 | margin: 5px 0 0 0; 89 | padding: 0; 90 | } 91 | 92 | div.sphinxsidebar p { 93 | color: #ffffff; 94 | } 95 | 96 | div.sphinxsidebar p.topless { 97 | margin: 5px 10px 10px 10px; 98 | } 99 | 100 | div.sphinxsidebar ul { 101 | margin: 10px; 102 | padding: 0; 103 | color: #ffffff; 104 | } 105 | 106 | div.sphinxsidebar a { 107 | color: #98dbcc; 108 | } 109 | 110 | div.sphinxsidebar input { 111 | border: 1px solid #98dbcc; 112 | font-family: sans-serif; 113 | font-size: 1em; 114 | } 115 | 116 | 117 | 118 | /* -- hyperlink styles ------------------------------------------------------ */ 119 | 120 | a { 121 | color: #355f7c; 122 | text-decoration: none; 123 | } 124 | 125 | a:visited { 126 | color: #355f7c; 127 | text-decoration: none; 128 | } 129 | 130 | a:hover { 131 | text-decoration: underline; 132 | } 133 | 134 | 135 | 136 | /* -- body styles ----------------------------------------------------------- */ 137 | 138 | div.body h1, 139 | div.body h2, 140 | div.body h3, 141 | div.body h4, 142 | div.body h5, 143 | div.body h6 { 144 | font-family: 'Trebuchet MS', sans-serif; 145 | background-color: #f2f2f2; 146 | font-weight: normal; 147 | color: #20435c; 148 | border-bottom: 1px solid #ccc; 149 | margin: 20px -20px 10px -20px; 150 | padding: 3px 0 3px 10px; 151 | } 152 | 153 | div.body h1 { margin-top: 0; font-size: 200%; } 154 | div.body h2 { font-size: 160%; } 155 | div.body h3 { font-size: 140%; } 156 | div.body h4 { font-size: 120%; } 157 | div.body h5 { font-size: 110%; } 158 | div.body h6 { font-size: 100%; } 159 | 160 | a.headerlink { 161 | color: #c60f0f; 162 | font-size: 0.8em; 163 | padding: 0 4px 0 4px; 164 | text-decoration: none; 165 | } 166 | 167 | a.headerlink:hover { 168 | background-color: #c60f0f; 169 | color: white; 170 | } 171 | 172 | div.body p, div.body dd, div.body li { 173 | text-align: justify; 174 | line-height: 130%; 175 | } 176 | 177 | div.admonition p.admonition-title + p { 178 | display: inline; 179 | } 180 | 181 | div.admonition p { 182 | margin-bottom: 5px; 183 | } 184 | 185 | div.admonition pre { 186 | margin-bottom: 5px; 187 | } 188 | 189 | div.admonition ul, div.admonition ol { 190 | margin-bottom: 5px; 191 | } 192 | 193 | div.note { 194 | background-color: #eee; 195 | border: 1px solid #ccc; 196 | } 197 | 198 | div.seealso { 199 | background-color: #ffc; 200 | border: 1px solid #ff6; 201 | } 202 | 203 | div.topic { 204 | background-color: #eee; 205 | } 206 | 207 | div.warning { 208 | background-color: #ffe4e4; 209 | border: 1px solid #f66; 210 | } 211 | 212 | p.admonition-title { 213 | display: inline; 214 | } 215 | 216 | p.admonition-title:after { 217 | content: ":"; 218 | } 219 | 220 | pre { 221 | padding: 5px; 222 | background-color: #eeffcc; 223 | color: #333333; 224 | line-height: 120%; 225 | border: 1px solid #ac9; 226 | border-left: none; 227 | border-right: none; 228 | } 229 | 230 | tt { 231 | background-color: #ecf0f3; 232 | padding: 0 1px 0 1px; 233 | font-size: 0.95em; 234 | } 235 | 236 | th { 237 | background-color: #ede; 238 | } 239 | 240 | .warning tt { 241 | background: #efc2c2; 242 | } 243 | 244 | .note tt { 245 | background: #d6d6d6; 246 | } 247 | 248 | .viewcode-back { 249 | font-family: sans-serif; 250 | } 251 | 252 | div.viewcode-block:target { 253 | background-color: #f4debf; 254 | border-top: 1px solid #ac9; 255 | border-bottom: 1px solid #ac9; 256 | } -------------------------------------------------------------------------------- /docs/build/html/_static/doctools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * doctools.js 3 | * ~~~~~~~~~~~ 4 | * 5 | * Sphinx JavaScript utilities for all documentation. 6 | * 7 | * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /** 13 | * select a different prefix for underscore 14 | */ 15 | $u = _.noConflict(); 16 | 17 | /** 18 | * make the code below compatible with browsers without 19 | * an installed firebug like debugger 20 | if (!window.console || !console.firebug) { 21 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir", 22 | "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", 23 | "profile", "profileEnd"]; 24 | window.console = {}; 25 | for (var i = 0; i < names.length; ++i) 26 | window.console[names[i]] = function() {}; 27 | } 28 | */ 29 | 30 | /** 31 | * small helper function to urldecode strings 32 | */ 33 | jQuery.urldecode = function(x) { 34 | return decodeURIComponent(x).replace(/\+/g, ' '); 35 | }; 36 | 37 | /** 38 | * small helper function to urlencode strings 39 | */ 40 | jQuery.urlencode = encodeURIComponent; 41 | 42 | /** 43 | * This function returns the parsed url parameters of the 44 | * current request. Multiple values per key are supported, 45 | * it will always return arrays of strings for the value parts. 46 | */ 47 | jQuery.getQueryParameters = function(s) { 48 | if (typeof s == 'undefined') 49 | s = document.location.search; 50 | var parts = s.substr(s.indexOf('?') + 1).split('&'); 51 | var result = {}; 52 | for (var i = 0; i < parts.length; i++) { 53 | var tmp = parts[i].split('=', 2); 54 | var key = jQuery.urldecode(tmp[0]); 55 | var value = jQuery.urldecode(tmp[1]); 56 | if (key in result) 57 | result[key].push(value); 58 | else 59 | result[key] = [value]; 60 | } 61 | return result; 62 | }; 63 | 64 | /** 65 | * highlight a given string on a jquery object by wrapping it in 66 | * span elements with the given class name. 67 | */ 68 | jQuery.fn.highlightText = function(text, className) { 69 | function highlight(node) { 70 | if (node.nodeType == 3) { 71 | var val = node.nodeValue; 72 | var pos = val.toLowerCase().indexOf(text); 73 | if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) { 74 | var span = document.createElement("span"); 75 | span.className = className; 76 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 77 | node.parentNode.insertBefore(span, node.parentNode.insertBefore( 78 | document.createTextNode(val.substr(pos + text.length)), 79 | node.nextSibling)); 80 | node.nodeValue = val.substr(0, pos); 81 | } 82 | } 83 | else if (!jQuery(node).is("button, select, textarea")) { 84 | jQuery.each(node.childNodes, function() { 85 | highlight(this); 86 | }); 87 | } 88 | } 89 | return this.each(function() { 90 | highlight(this); 91 | }); 92 | }; 93 | 94 | /** 95 | * Small JavaScript module for the documentation. 96 | */ 97 | var Documentation = { 98 | 99 | init : function() { 100 | this.fixFirefoxAnchorBug(); 101 | this.highlightSearchWords(); 102 | this.initIndexTable(); 103 | }, 104 | 105 | /** 106 | * i18n support 107 | */ 108 | TRANSLATIONS : {}, 109 | PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; }, 110 | LOCALE : 'unknown', 111 | 112 | // gettext and ngettext don't access this so that the functions 113 | // can safely bound to a different name (_ = Documentation.gettext) 114 | gettext : function(string) { 115 | var translated = Documentation.TRANSLATIONS[string]; 116 | if (typeof translated == 'undefined') 117 | return string; 118 | return (typeof translated == 'string') ? translated : translated[0]; 119 | }, 120 | 121 | ngettext : function(singular, plural, n) { 122 | var translated = Documentation.TRANSLATIONS[singular]; 123 | if (typeof translated == 'undefined') 124 | return (n == 1) ? singular : plural; 125 | return translated[Documentation.PLURALEXPR(n)]; 126 | }, 127 | 128 | addTranslations : function(catalog) { 129 | for (var key in catalog.messages) 130 | this.TRANSLATIONS[key] = catalog.messages[key]; 131 | this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); 132 | this.LOCALE = catalog.locale; 133 | }, 134 | 135 | /** 136 | * add context elements like header anchor links 137 | */ 138 | addContextElements : function() { 139 | $('div[id] > :header:first').each(function() { 140 | $('\u00B6'). 141 | attr('href', '#' + this.id). 142 | attr('title', _('Permalink to this headline')). 143 | appendTo(this); 144 | }); 145 | $('dt[id]').each(function() { 146 | $('\u00B6'). 147 | attr('href', '#' + this.id). 148 | attr('title', _('Permalink to this definition')). 149 | appendTo(this); 150 | }); 151 | }, 152 | 153 | /** 154 | * workaround a firefox stupidity 155 | */ 156 | fixFirefoxAnchorBug : function() { 157 | if (document.location.hash && $.browser.mozilla) 158 | window.setTimeout(function() { 159 | document.location.href += ''; 160 | }, 10); 161 | }, 162 | 163 | /** 164 | * highlight the search words provided in the url in the text 165 | */ 166 | highlightSearchWords : function() { 167 | var params = $.getQueryParameters(); 168 | var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; 169 | if (terms.length) { 170 | var body = $('div.body'); 171 | if (!body.length) { 172 | body = $('body'); 173 | } 174 | window.setTimeout(function() { 175 | $.each(terms, function() { 176 | body.highlightText(this.toLowerCase(), 'highlighted'); 177 | }); 178 | }, 10); 179 | $('') 181 | .appendTo($('#searchbox')); 182 | } 183 | }, 184 | 185 | /** 186 | * init the domain index toggle buttons 187 | */ 188 | initIndexTable : function() { 189 | var togglers = $('img.toggler').click(function() { 190 | var src = $(this).attr('src'); 191 | var idnum = $(this).attr('id').substr(7); 192 | $('tr.cg-' + idnum).toggle(); 193 | if (src.substr(-9) == 'minus.png') 194 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); 195 | else 196 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); 197 | }).css('display', ''); 198 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { 199 | togglers.click(); 200 | } 201 | }, 202 | 203 | /** 204 | * helper function to hide the search marks again 205 | */ 206 | hideSearchWords : function() { 207 | $('#searchbox .highlight-link').fadeOut(300); 208 | $('span.highlighted').removeClass('highlighted'); 209 | }, 210 | 211 | /** 212 | * make the url absolute 213 | */ 214 | makeURL : function(relativeURL) { 215 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; 216 | }, 217 | 218 | /** 219 | * get the current relative url 220 | */ 221 | getCurrentURL : function() { 222 | var path = document.location.pathname; 223 | var parts = path.split(/\//); 224 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { 225 | if (this == '..') 226 | parts.pop(); 227 | }); 228 | var url = parts.join('/'); 229 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1); 230 | } 231 | }; 232 | 233 | // quick alias for translations 234 | _ = Documentation.gettext; 235 | 236 | $(document).ready(function() { 237 | Documentation.init(); 238 | }); 239 | -------------------------------------------------------------------------------- /docs/build/html/_static/down-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/down-pressed.png -------------------------------------------------------------------------------- /docs/build/html/_static/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/down.png -------------------------------------------------------------------------------- /docs/build/html/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/file.png -------------------------------------------------------------------------------- /docs/build/html/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/minus.png -------------------------------------------------------------------------------- /docs/build/html/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/plus.png -------------------------------------------------------------------------------- /docs/build/html/_static/pygments.css: -------------------------------------------------------------------------------- 1 | .highlight .hll { background-color: #ffffcc } 2 | .highlight { background: #eeffcc; } 3 | .highlight .c { color: #408090; font-style: italic } /* Comment */ 4 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 5 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */ 6 | .highlight .o { color: #666666 } /* Operator */ 7 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ 8 | .highlight .cp { color: #007020 } /* Comment.Preproc */ 9 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ 10 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ 11 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 12 | .highlight .ge { font-style: italic } /* Generic.Emph */ 13 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 14 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 15 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 16 | .highlight .go { color: #333333 } /* Generic.Output */ 17 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 18 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 19 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 20 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 21 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 22 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 23 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ 24 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */ 25 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 26 | .highlight .kt { color: #902000 } /* Keyword.Type */ 27 | .highlight .m { color: #208050 } /* Literal.Number */ 28 | .highlight .s { color: #4070a0 } /* Literal.String */ 29 | .highlight .na { color: #4070a0 } /* Name.Attribute */ 30 | .highlight .nb { color: #007020 } /* Name.Builtin */ 31 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 32 | .highlight .no { color: #60add5 } /* Name.Constant */ 33 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 34 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 35 | .highlight .ne { color: #007020 } /* Name.Exception */ 36 | .highlight .nf { color: #06287e } /* Name.Function */ 37 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ 38 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 39 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ 40 | .highlight .nv { color: #bb60d5 } /* Name.Variable */ 41 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ 42 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 43 | .highlight .mb { color: #208050 } /* Literal.Number.Bin */ 44 | .highlight .mf { color: #208050 } /* Literal.Number.Float */ 45 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */ 46 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */ 47 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */ 48 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ 49 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */ 50 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 51 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */ 52 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 53 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ 54 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 55 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */ 56 | .highlight .sr { color: #235388 } /* Literal.String.Regex */ 57 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */ 58 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */ 59 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ 60 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ 61 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ 62 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ 63 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /docs/build/html/_static/sidebar.js: -------------------------------------------------------------------------------- 1 | /* 2 | * sidebar.js 3 | * ~~~~~~~~~~ 4 | * 5 | * This script makes the Sphinx sidebar collapsible. 6 | * 7 | * .sphinxsidebar contains .sphinxsidebarwrapper. This script adds 8 | * in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton 9 | * used to collapse and expand the sidebar. 10 | * 11 | * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden 12 | * and the width of the sidebar and the margin-left of the document 13 | * are decreased. When the sidebar is expanded the opposite happens. 14 | * This script saves a per-browser/per-session cookie used to 15 | * remember the position of the sidebar among the pages. 16 | * Once the browser is closed the cookie is deleted and the position 17 | * reset to the default (expanded). 18 | * 19 | * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. 20 | * :license: BSD, see LICENSE for details. 21 | * 22 | */ 23 | 24 | $(function() { 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | // global elements used by the functions. 34 | // the 'sidebarbutton' element is defined as global after its 35 | // creation, in the add_sidebar_button function 36 | var bodywrapper = $('.bodywrapper'); 37 | var sidebar = $('.sphinxsidebar'); 38 | var sidebarwrapper = $('.sphinxsidebarwrapper'); 39 | 40 | // for some reason, the document has no sidebar; do not run into errors 41 | if (!sidebar.length) return; 42 | 43 | // original margin-left of the bodywrapper and width of the sidebar 44 | // with the sidebar expanded 45 | var bw_margin_expanded = bodywrapper.css('margin-left'); 46 | var ssb_width_expanded = sidebar.width(); 47 | 48 | // margin-left of the bodywrapper and width of the sidebar 49 | // with the sidebar collapsed 50 | var bw_margin_collapsed = '.8em'; 51 | var ssb_width_collapsed = '.8em'; 52 | 53 | // colors used by the current theme 54 | var dark_color = $('.related').css('background-color'); 55 | var light_color = $('.document').css('background-color'); 56 | 57 | function sidebar_is_collapsed() { 58 | return sidebarwrapper.is(':not(:visible)'); 59 | } 60 | 61 | function toggle_sidebar() { 62 | if (sidebar_is_collapsed()) 63 | expand_sidebar(); 64 | else 65 | collapse_sidebar(); 66 | } 67 | 68 | function collapse_sidebar() { 69 | sidebarwrapper.hide(); 70 | sidebar.css('width', ssb_width_collapsed); 71 | bodywrapper.css('margin-left', bw_margin_collapsed); 72 | sidebarbutton.css({ 73 | 'margin-left': '0', 74 | 'height': bodywrapper.height() 75 | }); 76 | sidebarbutton.find('span').text('»'); 77 | sidebarbutton.attr('title', _('Expand sidebar')); 78 | document.cookie = 'sidebar=collapsed'; 79 | } 80 | 81 | function expand_sidebar() { 82 | bodywrapper.css('margin-left', bw_margin_expanded); 83 | sidebar.css('width', ssb_width_expanded); 84 | sidebarwrapper.show(); 85 | sidebarbutton.css({ 86 | 'margin-left': ssb_width_expanded-12, 87 | 'height': bodywrapper.height() 88 | }); 89 | sidebarbutton.find('span').text('«'); 90 | sidebarbutton.attr('title', _('Collapse sidebar')); 91 | document.cookie = 'sidebar=expanded'; 92 | } 93 | 94 | function add_sidebar_button() { 95 | sidebarwrapper.css({ 96 | 'float': 'left', 97 | 'margin-right': '0', 98 | 'width': ssb_width_expanded - 28 99 | }); 100 | // create the button 101 | sidebar.append( 102 | '
«
' 103 | ); 104 | var sidebarbutton = $('#sidebarbutton'); 105 | light_color = sidebarbutton.css('background-color'); 106 | // find the height of the viewport to center the '<<' in the page 107 | var viewport_height; 108 | if (window.innerHeight) 109 | viewport_height = window.innerHeight; 110 | else 111 | viewport_height = $(window).height(); 112 | sidebarbutton.find('span').css({ 113 | 'display': 'block', 114 | 'margin-top': (viewport_height - sidebar.position().top - 20) / 2 115 | }); 116 | 117 | sidebarbutton.click(toggle_sidebar); 118 | sidebarbutton.attr('title', _('Collapse sidebar')); 119 | sidebarbutton.css({ 120 | 'color': '#FFFFFF', 121 | 'border-left': '1px solid ' + dark_color, 122 | 'font-size': '1.2em', 123 | 'cursor': 'pointer', 124 | 'height': bodywrapper.height(), 125 | 'padding-top': '1px', 126 | 'margin-left': ssb_width_expanded - 12 127 | }); 128 | 129 | sidebarbutton.hover( 130 | function () { 131 | $(this).css('background-color', dark_color); 132 | }, 133 | function () { 134 | $(this).css('background-color', light_color); 135 | } 136 | ); 137 | } 138 | 139 | function set_position_from_cookie() { 140 | if (!document.cookie) 141 | return; 142 | var items = document.cookie.split(';'); 143 | for(var k=0; k2;a== 12 | null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= 13 | function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= 14 | e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= 15 | function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, 17 | c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}}; 24 | b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, 25 | 1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; 26 | b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; 27 | b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), 28 | function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ 29 | u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= 30 | function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= 31 | true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); 32 | -------------------------------------------------------------------------------- /docs/build/html/_static/up-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/up-pressed.png -------------------------------------------------------------------------------- /docs/build/html/_static/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/_static/up.png -------------------------------------------------------------------------------- /docs/build/html/modules.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | gptools — gptools 0.2 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 44 | 45 |
46 | 87 |
88 |
89 |

This Page

90 | 94 | 106 | 107 |
108 |
109 |
110 |
111 | 126 | 130 | 131 | -------------------------------------------------------------------------------- /docs/build/html/np-modindex.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Python Module Index — gptools 0.2 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 47 | 48 |
49 |
50 |
51 |
52 | 53 | 54 |

Python Module Index

55 | 56 |
57 | g 58 |
59 | 60 | 61 | 62 | 64 | 65 | 67 | 70 | 71 | 72 | 75 | 76 | 77 | 80 | 81 | 82 | 85 | 86 | 87 | 90 | 91 | 92 | 95 | 96 | 97 | 100 | 101 | 102 | 105 | 106 | 107 | 110 | 111 | 112 | 115 | 116 | 117 | 120 | 121 | 122 | 125 | 126 | 127 | 130 | 131 | 132 | 135 |
 
63 | g
68 | gptools 69 |
    73 | gptools.error_handling 74 |
    78 | gptools.gaussian_process 79 |
    83 | gptools.gp_utils 84 |
    88 | gptools.kernel 89 |
    93 | gptools.kernel.core 94 |
    98 | gptools.kernel.gibbs 99 |
    103 | gptools.kernel.matern 104 |
    108 | gptools.kernel.noise 109 |
    113 | gptools.kernel.rational_quadratic 114 |
    118 | gptools.kernel.squared_exponential 119 |
    123 | gptools.kernel.warping 124 |
    128 | gptools.mean 129 |
    133 | gptools.utils 134 |
136 | 137 | 138 |
139 |
140 |
141 |
142 |
143 | 155 | 156 |
157 |
158 |
159 |
160 | 175 | 179 | 180 | -------------------------------------------------------------------------------- /docs/build/html/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/html/objects.inv -------------------------------------------------------------------------------- /docs/build/html/py-modindex.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Python Module Index — gptools 0.2 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 47 | 48 |
49 |
50 |
51 |
52 | 53 | 54 |

Python Module Index

55 | 56 |
57 | g 58 |
59 | 60 | 61 | 62 | 64 | 65 | 67 | 70 | 71 | 72 | 75 | 76 | 77 | 80 | 81 | 82 | 85 | 86 | 87 | 90 | 91 | 92 | 95 | 96 | 97 | 100 | 101 | 102 | 105 | 106 | 107 | 110 | 111 | 112 | 115 | 116 | 117 | 120 | 121 | 122 | 125 | 126 | 127 | 130 | 131 | 132 | 135 |
 
63 | g
68 | gptools 69 |
    73 | gptools.error_handling 74 |
    78 | gptools.gaussian_process 79 |
    83 | gptools.gp_utils 84 |
    88 | gptools.kernel 89 |
    93 | gptools.kernel.core 94 |
    98 | gptools.kernel.gibbs 99 |
    103 | gptools.kernel.matern 104 |
    108 | gptools.kernel.noise 109 |
    113 | gptools.kernel.rational_quadratic 114 |
    118 | gptools.kernel.squared_exponential 119 |
    123 | gptools.kernel.warping 124 |
    128 | gptools.mean 129 |
    133 | gptools.utils 134 |
136 | 137 | 138 |
139 |
140 |
141 |
142 |
143 | 155 | 156 |
157 |
158 |
159 |
160 | 175 | 179 | 180 | -------------------------------------------------------------------------------- /docs/build/html/search.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Search — gptools 0.2 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 52 | 53 |
54 |
55 |
56 |
57 | 58 |

Search

59 |
60 | 61 |

62 | Please activate JavaScript to enable the search 63 | functionality. 64 |

65 |
66 |

67 | From here you can search these documents. Enter your search 68 | words into the box below and click "search". Note that the search 69 | function will automatically search for all of the words. Pages 70 | containing fewer words won't appear in the result list. 71 |

72 |
73 | 74 | 75 | 76 |
77 | 78 |
79 | 80 |
81 | 82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 | 106 | 110 | 111 | -------------------------------------------------------------------------------- /docs/build/latex/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx LaTeX output 2 | 3 | ALLDOCS = $(basename $(wildcard *.tex)) 4 | ALLPDF = $(addsuffix .pdf,$(ALLDOCS)) 5 | ALLDVI = $(addsuffix .dvi,$(ALLDOCS)) 6 | 7 | # Prefix for archive names 8 | ARCHIVEPRREFIX = 9 | # Additional LaTeX options 10 | LATEXOPTS = 11 | 12 | all: $(ALLPDF) 13 | all-pdf: $(ALLPDF) 14 | all-dvi: $(ALLDVI) 15 | all-ps: all-dvi 16 | for f in *.dvi; do dvips $$f; done 17 | 18 | all-pdf-ja: 19 | for f in *.pdf *.png *.gif *.jpg *.jpeg; do extractbb $$f; done 20 | for f in *.tex; do platex -kanji=utf8 $(LATEXOPTS) $$f; done 21 | for f in *.tex; do platex -kanji=utf8 $(LATEXOPTS) $$f; done 22 | for f in *.tex; do platex -kanji=utf8 $(LATEXOPTS) $$f; done 23 | -for f in *.idx; do mendex -U -f -d "`basename $$f .idx`.dic" -s python.ist $$f; done 24 | for f in *.tex; do platex -kanji=utf8 $(LATEXOPTS) $$f; done 25 | for f in *.tex; do platex -kanji=utf8 $(LATEXOPTS) $$f; done 26 | for f in *.dvi; do dvipdfmx $$f; done 27 | 28 | zip: all-$(FMT) 29 | mkdir $(ARCHIVEPREFIX)docs-$(FMT) 30 | cp $(ALLPDF) $(ARCHIVEPREFIX)docs-$(FMT) 31 | zip -q -r -9 $(ARCHIVEPREFIX)docs-$(FMT).zip $(ARCHIVEPREFIX)docs-$(FMT) 32 | rm -r $(ARCHIVEPREFIX)docs-$(FMT) 33 | 34 | tar: all-$(FMT) 35 | mkdir $(ARCHIVEPREFIX)docs-$(FMT) 36 | cp $(ALLPDF) $(ARCHIVEPREFIX)docs-$(FMT) 37 | tar cf $(ARCHIVEPREFIX)docs-$(FMT).tar $(ARCHIVEPREFIX)docs-$(FMT) 38 | rm -r $(ARCHIVEPREFIX)docs-$(FMT) 39 | 40 | bz2: tar 41 | bzip2 -9 -k $(ARCHIVEPREFIX)docs-$(FMT).tar 42 | 43 | # The number of LaTeX runs is quite conservative, but I don't expect it 44 | # to get run often, so the little extra time won't hurt. 45 | %.dvi: %.tex 46 | latex $(LATEXOPTS) '$<' 47 | latex $(LATEXOPTS) '$<' 48 | latex $(LATEXOPTS) '$<' 49 | -makeindex -s python.ist '$(basename $<).idx' 50 | latex $(LATEXOPTS) '$<' 51 | latex $(LATEXOPTS) '$<' 52 | 53 | %.pdf: %.tex 54 | pdflatex $(LATEXOPTS) '$<' 55 | pdflatex $(LATEXOPTS) '$<' 56 | pdflatex $(LATEXOPTS) '$<' 57 | -makeindex -s python.ist '$(basename $<).idx' 58 | pdflatex $(LATEXOPTS) '$<' 59 | pdflatex $(LATEXOPTS) '$<' 60 | 61 | clean: 62 | rm -f *.dvi *.log *.ind *.aux *.toc *.syn *.idx *.out *.ilg *.pla 63 | 64 | .PHONY: all all-pdf all-dvi all-ps clean 65 | .PHONY: all-pdf-ja 66 | 67 | -------------------------------------------------------------------------------- /docs/build/latex/gptools.ilg: -------------------------------------------------------------------------------- 1 | This is makeindex, version 2.15 [TeX Live 2014] (kpathsea + Thai support). 2 | Scanning style file ./python.ist......done (6 attributes redefined, 0 ignored). 3 | Scanning input file gptools.idx....done (209 entries accepted, 0 rejected). 4 | Sorting entries.....done (1729 comparisons). 5 | Generating output file gptools.ind....done (289 lines written, 0 warnings). 6 | Output written in gptools.ind. 7 | Transcript written in gptools.ilg. 8 | -------------------------------------------------------------------------------- /docs/build/latex/gptools.out: -------------------------------------------------------------------------------- 1 | \BOOKMARK [0][-]{chapter.1}{Overview}{}% 1 2 | \BOOKMARK [0][-]{chapter.2}{Kernels}{}% 2 3 | \BOOKMARK [0][-]{chapter.3}{Notes}{}% 3 4 | \BOOKMARK [0][-]{chapter.4}{Contents}{}% 4 5 | \BOOKMARK [1][-]{section.4.1}{gptools package}{chapter.4}% 5 6 | \BOOKMARK [2][-]{subsection.4.1.1}{Subpackages}{section.4.1}% 6 7 | \BOOKMARK [3][-]{subsubsection*.3}{gptools.kernel package}{subsection.4.1.1}% 7 8 | \BOOKMARK [2][-]{subsection.4.1.2}{Submodules}{section.4.1}% 8 9 | \BOOKMARK [2][-]{subsection.4.1.3}{gptools.error\137handling module}{section.4.1}% 9 10 | \BOOKMARK [2][-]{subsection.4.1.4}{gptools.gaussian\137process module}{section.4.1}% 10 11 | \BOOKMARK [2][-]{subsection.4.1.5}{gptools.gp\137utils module}{section.4.1}% 11 12 | \BOOKMARK [2][-]{subsection.4.1.6}{gptools.mean module}{section.4.1}% 12 13 | \BOOKMARK [2][-]{subsection.4.1.7}{gptools.utils module}{section.4.1}% 13 14 | \BOOKMARK [2][-]{subsection.4.1.8}{Module contents}{section.4.1}% 14 15 | \BOOKMARK [0][-]{chapter.5}{Indices and tables}{}% 15 16 | \BOOKMARK [0][-]{chapter*.216}{Bibliography}{}% 16 17 | \BOOKMARK [0][-]{section*.219}{Python Module Index}{}% 17 18 | \BOOKMARK [0][-]{section*.220}{Python Module Index}{}% 18 19 | \BOOKMARK [0][-]{section*.221}{Index}{}% 19 20 | -------------------------------------------------------------------------------- /docs/build/latex/gptools.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markchil/gptools/045e72c6982fc40a98597dedcab2583d2d98195e/docs/build/latex/gptools.pdf -------------------------------------------------------------------------------- /docs/build/latex/gptools.toc: -------------------------------------------------------------------------------- 1 | \select@language {english} 2 | \contentsline {chapter}{\numberline {1}Overview}{3}{chapter.1} 3 | \contentsline {chapter}{\numberline {2}Kernels}{5}{chapter.2} 4 | \contentsline {chapter}{\numberline {3}Notes}{7}{chapter.3} 5 | \contentsline {chapter}{\numberline {4}Contents}{9}{chapter.4} 6 | \contentsline {section}{\numberline {4.1}gptools package}{9}{section.4.1} 7 | \contentsline {subsection}{\numberline {4.1.1}Subpackages}{9}{subsection.4.1.1} 8 | \contentsline {subsubsection}{gptools.kernel package}{9}{subsubsection*.3} 9 | \contentsline {paragraph}{Submodules}{9}{paragraph*.4} 10 | \contentsline {paragraph}{gptools.kernel.core module}{9}{paragraph*.5} 11 | \contentsline {paragraph}{Attributes}{10}{paragraph*.7} 12 | \contentsline {paragraph}{Notes}{11}{paragraph*.10} 13 | \contentsline {paragraph}{Notes}{12}{paragraph*.20} 14 | \contentsline {paragraph}{Attributes}{15}{paragraph*.34} 15 | \contentsline {paragraph}{gptools.kernel.gibbs module}{16}{paragraph*.40} 16 | \contentsline {paragraph}{gptools.kernel.matern module}{24}{paragraph*.57} 17 | \contentsline {paragraph}{gptools.kernel.noise module}{28}{paragraph*.67} 18 | \contentsline {paragraph}{gptools.kernel.rational\_quadratic module}{29}{paragraph*.72} 19 | \contentsline {paragraph}{gptools.kernel.squared\_exponential module}{30}{paragraph*.74} 20 | \contentsline {paragraph}{gptools.kernel.warping module}{31}{paragraph*.77} 21 | \contentsline {paragraph}{References}{34}{paragraph*.88} 22 | \contentsline {paragraph}{References}{35}{paragraph*.101} 23 | \contentsline {paragraph}{Module contents}{36}{paragraph*.103} 24 | \contentsline {subsection}{\numberline {4.1.2}Submodules}{36}{subsection.4.1.2} 25 | \contentsline {subsection}{\numberline {4.1.3}gptools.error\_handling module}{36}{subsection.4.1.3} 26 | \contentsline {subsection}{\numberline {4.1.4}gptools.gaussian\_process module}{36}{subsection.4.1.4} 27 | \contentsline {paragraph}{Attributes}{38}{paragraph*.106} 28 | \contentsline {subsection}{\numberline {4.1.5}gptools.gp\_utils module}{51}{subsection.4.1.5} 29 | \contentsline {subsection}{\numberline {4.1.6}gptools.mean module}{52}{subsection.4.1.6} 30 | \contentsline {subsection}{\numberline {4.1.7}gptools.utils module}{55}{subsection.4.1.7} 31 | \contentsline {subsection}{\numberline {4.1.8}Module contents}{64}{subsection.4.1.8} 32 | \contentsline {chapter}{\numberline {5}Indices and tables}{65}{chapter.5} 33 | \contentsline {chapter}{Bibliography}{67}{chapter*.216} 34 | \contentsline {chapter}{Python Module Index}{69}{section*.219} 35 | \contentsline {chapter}{Python Module Index}{71}{section*.220} 36 | \contentsline {chapter}{Index}{73}{section*.221} 37 | -------------------------------------------------------------------------------- /docs/build/latex/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 | -------------------------------------------------------------------------------- /docs/build/latex/sphinxhowto.cls: -------------------------------------------------------------------------------- 1 | % 2 | % sphinxhowto.cls for Sphinx (http://sphinx-doc.org/) 3 | % 4 | 5 | \NeedsTeXFormat{LaTeX2e}[1995/12/01] 6 | \ProvidesClass{sphinxhowto}[2009/06/02 Document class (Sphinx HOWTO)] 7 | 8 | % 'oneside' option overriding the 'twoside' default 9 | \newif\if@oneside 10 | \DeclareOption{oneside}{\@onesidetrue} 11 | % Pass remaining document options to the parent class. 12 | \DeclareOption*{\PassOptionsToClass{\CurrentOption}{\sphinxdocclass}} 13 | \ProcessOptions\relax 14 | 15 | % Default to two-side document 16 | \if@oneside 17 | % nothing to do (oneside is the default) 18 | \else 19 | \PassOptionsToClass{twoside}{\sphinxdocclass} 20 | \fi 21 | 22 | \LoadClass{\sphinxdocclass} 23 | 24 | % Set some sane defaults for section numbering depth and TOC depth. You can 25 | % reset these counters in your preamble. 26 | % 27 | \setcounter{secnumdepth}{2} 28 | 29 | % Change the title page to look a bit better, and fit in with the fncychap 30 | % ``Bjarne'' style a bit better. 31 | % 32 | \renewcommand{\maketitle}{ 33 | \rule{\textwidth}{1pt} 34 | \ifsphinxpdfoutput 35 | \begingroup 36 | % These \defs are required to deal with multi-line authors; it 37 | % changes \\ to ', ' (comma-space), making it pass muster for 38 | % generating document info in the PDF file. 39 | \def\\{, } 40 | \def\and{and } 41 | \pdfinfo{ 42 | /Author (\@author) 43 | /Title (\@title) 44 | } 45 | \endgroup 46 | \fi 47 | \begin{flushright} 48 | \sphinxlogo% 49 | {\rm\Huge\py@HeaderFamily \@title} \par 50 | {\em\large\py@HeaderFamily \py@release\releaseinfo} \par 51 | \vspace{25pt} 52 | {\Large\py@HeaderFamily 53 | \begin{tabular}[t]{c} 54 | \@author 55 | \end{tabular}} \par 56 | \vspace{25pt} 57 | \@date \par 58 | \py@authoraddress \par 59 | \end{flushright} 60 | \@thanks 61 | \setcounter{footnote}{0} 62 | \let\thanks\relax\let\maketitle\relax 63 | %\gdef\@thanks{}\gdef\@author{}\gdef\@title{} 64 | } 65 | 66 | \let\py@OldTableofcontents=\tableofcontents 67 | \renewcommand{\tableofcontents}{ 68 | \begingroup 69 | \parskip = 0mm 70 | \py@OldTableofcontents 71 | \endgroup 72 | \rule{\textwidth}{1pt} 73 | \vspace{12pt} 74 | } 75 | 76 | \@ifundefined{fancyhf}{ 77 | \pagestyle{plain}}{ 78 | \pagestyle{normal}} % start this way; change for 79 | \pagenumbering{arabic} % ToC & chapters 80 | 81 | \thispagestyle{empty} 82 | 83 | % Fix the bibliography environment to add an entry to the Table of 84 | % Contents. 85 | % For an article document class this environment is a section, 86 | % so no page break before it. 87 | \let\py@OldThebibliography=\thebibliography 88 | \renewcommand{\thebibliography}[1]{ 89 | \phantomsection 90 | \py@OldThebibliography{1} 91 | \addcontentsline{toc}{section}{\bibname} 92 | } 93 | 94 | % Same for the indices. 95 | % The memoir class already does this, so we don't duplicate it in that case. 96 | % 97 | \@ifclassloaded{memoir}{}{ 98 | \let\py@OldTheindex=\theindex 99 | \renewcommand{\theindex}{ 100 | \phantomsection 101 | \py@OldTheindex 102 | \addcontentsline{toc}{section}{\indexname} 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /docs/build/latex/sphinxmanual.cls: -------------------------------------------------------------------------------- 1 | % 2 | % sphinxmanual.cls for Sphinx (http://sphinx-doc.org/) 3 | % 4 | 5 | \NeedsTeXFormat{LaTeX2e}[1995/12/01] 6 | \ProvidesClass{sphinxmanual}[2009/06/02 Document class (Sphinx manual)] 7 | 8 | % chapters starting at odd pages (overridden by 'openany' document option) 9 | \PassOptionsToClass{openright}{\sphinxdocclass} 10 | 11 | % 'oneside' option overriding the 'twoside' default 12 | \newif\if@oneside 13 | \DeclareOption{oneside}{\@onesidetrue} 14 | % Pass remaining document options to the parent class. 15 | \DeclareOption*{\PassOptionsToClass{\CurrentOption}{\sphinxdocclass}} 16 | \ProcessOptions\relax 17 | 18 | % Defaults two-side document 19 | \if@oneside 20 | % nothing to do (oneside is the default) 21 | \else 22 | \PassOptionsToClass{twoside}{\sphinxdocclass} 23 | \fi 24 | 25 | \LoadClass{\sphinxdocclass} 26 | 27 | % Set some sane defaults for section numbering depth and TOC depth. You can 28 | % reset these counters in your preamble. 29 | % 30 | \setcounter{secnumdepth}{2} 31 | \setcounter{tocdepth}{1} 32 | 33 | % Change the title page to look a bit better, and fit in with the fncychap 34 | % ``Bjarne'' style a bit better. 35 | % 36 | \renewcommand{\maketitle}{% 37 | \begin{titlepage}% 38 | \let\footnotesize\small 39 | \let\footnoterule\relax 40 | \rule{\textwidth}{1pt}% 41 | \ifsphinxpdfoutput 42 | \begingroup 43 | % These \defs are required to deal with multi-line authors; it 44 | % changes \\ to ', ' (comma-space), making it pass muster for 45 | % generating document info in the PDF file. 46 | \def\\{, } 47 | \def\and{and } 48 | \pdfinfo{ 49 | /Author (\@author) 50 | /Title (\@title) 51 | } 52 | \endgroup 53 | \fi 54 | \begin{flushright}% 55 | \sphinxlogo% 56 | {\rm\Huge\py@HeaderFamily \@title \par}% 57 | {\em\LARGE\py@HeaderFamily \py@release\releaseinfo \par} 58 | \vfill 59 | {\LARGE\py@HeaderFamily 60 | \begin{tabular}[t]{c} 61 | \@author 62 | \end{tabular} 63 | \par} 64 | \vfill\vfill 65 | {\large 66 | \@date \par 67 | \vfill 68 | \py@authoraddress \par 69 | }% 70 | \end{flushright}%\par 71 | \@thanks 72 | \end{titlepage}% 73 | \cleardoublepage% 74 | \setcounter{footnote}{0}% 75 | \let\thanks\relax\let\maketitle\relax 76 | %\gdef\@thanks{}\gdef\@author{}\gdef\@title{} 77 | } 78 | 79 | 80 | % Catch the end of the {abstract} environment, but here make sure the abstract 81 | % is followed by a blank page if the 'openright' option is used. 82 | % 83 | \let\py@OldEndAbstract=\endabstract 84 | \renewcommand{\endabstract}{ 85 | \if@openright 86 | \ifodd\value{page} 87 | \typeout{Adding blank page after the abstract.} 88 | \vfil\pagebreak 89 | \fi 90 | \fi 91 | \py@OldEndAbstract 92 | } 93 | 94 | % This wraps the \tableofcontents macro with all the magic to get the spacing 95 | % right and have the right number of pages if the 'openright' option has been 96 | % used. This eliminates a fair amount of crud in the individual document files. 97 | % 98 | \let\py@OldTableofcontents=\tableofcontents 99 | \renewcommand{\tableofcontents}{% 100 | \pagenumbering{roman}% 101 | \setcounter{page}{1}% 102 | \pagebreak% 103 | \pagestyle{plain}% 104 | {% 105 | \parskip = 0mm% 106 | \py@OldTableofcontents% 107 | \if@openright% 108 | \ifodd\value{page}% 109 | \typeout{Adding blank page after the table of contents.}% 110 | \pagebreak\hspace{0pt}% 111 | \fi% 112 | \fi% 113 | \cleardoublepage% 114 | }% 115 | \pagenumbering{arabic}% 116 | \@ifundefined{fancyhf}{}{\pagestyle{normal}}% 117 | } 118 | \pagenumbering{alph} 119 | 120 | % This is needed to get the width of the section # area wide enough in the 121 | % library reference. Doing it here keeps it the same for all the manuals. 122 | % 123 | \renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.6em}} 124 | \renewcommand*\l@subsection{\@dottedtocline{2}{4.1em}{3.5em}} 125 | 126 | % Fix the bibliography environment to add an entry to the Table of 127 | % Contents. 128 | % For a report document class this environment is a chapter. 129 | \let\py@OldThebibliography=\thebibliography 130 | \renewcommand{\thebibliography}[1]{ 131 | \cleardoublepage 132 | \phantomsection 133 | \py@OldThebibliography{1} 134 | \addcontentsline{toc}{chapter}{\bibname} 135 | } 136 | 137 | % Same for the indices. 138 | % The memoir class already does this, so we don't duplicate it in that case. 139 | % 140 | \@ifclassloaded{memoir}{}{ 141 | \let\py@OldTheindex=\theindex 142 | \renewcommand{\theindex}{ 143 | \cleardoublepage 144 | \phantomsection 145 | \py@OldTheindex 146 | \addcontentsline{toc}{chapter}{\indexname} 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source 10 | set I18NSPHINXOPTS=%SPHINXOPTS% source 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. linkcheck to check all external links for integrity 37 | echo. doctest to run all doctests embedded in the documentation if enabled 38 | goto end 39 | ) 40 | 41 | if "%1" == "clean" ( 42 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 43 | del /q /s %BUILDDIR%\* 44 | goto end 45 | ) 46 | 47 | if "%1" == "html" ( 48 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 49 | if errorlevel 1 exit /b 1 50 | echo. 51 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 52 | goto end 53 | ) 54 | 55 | if "%1" == "dirhtml" ( 56 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 57 | if errorlevel 1 exit /b 1 58 | echo. 59 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 60 | goto end 61 | ) 62 | 63 | if "%1" == "singlehtml" ( 64 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 68 | goto end 69 | ) 70 | 71 | if "%1" == "pickle" ( 72 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished; now you can process the pickle files. 76 | goto end 77 | ) 78 | 79 | if "%1" == "json" ( 80 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished; now you can process the JSON files. 84 | goto end 85 | ) 86 | 87 | if "%1" == "htmlhelp" ( 88 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can run HTML Help Workshop with the ^ 92 | .hhp project file in %BUILDDIR%/htmlhelp. 93 | goto end 94 | ) 95 | 96 | if "%1" == "qthelp" ( 97 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 98 | if errorlevel 1 exit /b 1 99 | echo. 100 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 101 | .qhcp project file in %BUILDDIR%/qthelp, like this: 102 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\gptools.qhcp 103 | echo.To view the help file: 104 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\gptools.ghc 105 | goto end 106 | ) 107 | 108 | if "%1" == "devhelp" ( 109 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 110 | if errorlevel 1 exit /b 1 111 | echo. 112 | echo.Build finished. 113 | goto end 114 | ) 115 | 116 | if "%1" == "epub" ( 117 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 118 | if errorlevel 1 exit /b 1 119 | echo. 120 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 121 | goto end 122 | ) 123 | 124 | if "%1" == "latex" ( 125 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 129 | goto end 130 | ) 131 | 132 | if "%1" == "text" ( 133 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The text files are in %BUILDDIR%/text. 137 | goto end 138 | ) 139 | 140 | if "%1" == "man" ( 141 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 145 | goto end 146 | ) 147 | 148 | if "%1" == "texinfo" ( 149 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 150 | if errorlevel 1 exit /b 1 151 | echo. 152 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 153 | goto end 154 | ) 155 | 156 | if "%1" == "gettext" ( 157 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 158 | if errorlevel 1 exit /b 1 159 | echo. 160 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 161 | goto end 162 | ) 163 | 164 | if "%1" == "changes" ( 165 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 166 | if errorlevel 1 exit /b 1 167 | echo. 168 | echo.The overview file is in %BUILDDIR%/changes. 169 | goto end 170 | ) 171 | 172 | if "%1" == "linkcheck" ( 173 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 174 | if errorlevel 1 exit /b 1 175 | echo. 176 | echo.Link check complete; look for any errors in the above output ^ 177 | or in %BUILDDIR%/linkcheck/output.txt. 178 | goto end 179 | ) 180 | 181 | if "%1" == "doctest" ( 182 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 183 | if errorlevel 1 exit /b 1 184 | echo. 185 | echo.Testing of doctests in the sources finished, look at the ^ 186 | results in %BUILDDIR%/doctest/output.txt. 187 | goto end 188 | ) 189 | 190 | :end 191 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # gptools documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Sep 3 12:06:03 2013. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | sys.path.insert(0, os.path.abspath('../..')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.pngmath', 'sphinx.ext.viewcode', 'numpydoc'] # 29 | 30 | # Addition: Get constructor docstring properly: 31 | autoclass_content = 'class' 32 | # Keep things in module order: 33 | autodoc_member_order = 'bysource' 34 | # Document special methods: 35 | autodoc_default_flags = ['members', 'special-members', 'show-inheritance'] 36 | # Turn off autosummary stuff to prevent errors -- would be better to fix this. 37 | numpydoc_show_class_members = False 38 | # Set up things to be skipped: 39 | def yes_skip_member(app, what, name, obj, skip, options): 40 | skip_classes = ['__init__', '__dict__', '__module__', '__weakref__', '__doc__'] 41 | return name in skip_classes or skip 42 | def setup(app): 43 | app.connect('autodoc-skip-member', yes_skip_member) 44 | 45 | # Add any paths that contain templates here, relative to this directory. 46 | templates_path = ['_templates'] 47 | 48 | # The suffix of source filenames. 49 | source_suffix = '.rst' 50 | 51 | # The encoding of source files. 52 | #source_encoding = 'utf-8-sig' 53 | 54 | # The master toctree document. 55 | master_doc = 'index' 56 | 57 | # General information about the project. 58 | project = u'gptools' 59 | copyright = u'2015, Mark Chilenski' 60 | 61 | # The version info for the project you're documenting, acts as replacement for 62 | # |version| and |release|, also used in various other places throughout the 63 | # built documents. 64 | # 65 | # The short X.Y version. 66 | version = '0.2.2' 67 | # The full version, including alpha/beta/rc tags. 68 | release = '0.2.2' 69 | 70 | # The language for content autogenerated by Sphinx. Refer to documentation 71 | # for a list of supported languages. 72 | #language = None 73 | 74 | # There are two options for replacing |today|: either, you set today to some 75 | # non-false value, then it is used: 76 | #today = '' 77 | # Else, today_fmt is used as the format for a strftime call. 78 | #today_fmt = '%B %d, %Y' 79 | 80 | # List of patterns, relative to source directory, that match files and 81 | # directories to ignore when looking for source files. 82 | exclude_patterns = [] 83 | 84 | # The reST default role (used for this markup: `text`) to use for all documents. 85 | #default_role = None 86 | 87 | # If true, '()' will be appended to :func: etc. cross-reference text. 88 | #add_function_parentheses = True 89 | 90 | # If true, the current module name will be prepended to all description 91 | # unit titles (such as .. function::). 92 | #add_module_names = True 93 | 94 | # If true, sectionauthor and moduleauthor directives will be shown in the 95 | # output. They are ignored by default. 96 | #show_authors = False 97 | 98 | # The name of the Pygments (syntax highlighting) style to use. 99 | pygments_style = 'sphinx' 100 | 101 | # A list of ignored prefixes for module index sorting. 102 | #modindex_common_prefix = [] 103 | 104 | 105 | # -- Options for HTML output --------------------------------------------------- 106 | 107 | # The theme to use for HTML and HTML Help pages. See the documentation for 108 | # a list of builtin themes. 109 | html_theme = 'default' 110 | 111 | # Theme options are theme-specific and customize the look and feel of a theme 112 | # further. For a list of options available for each theme, see the 113 | # documentation. 114 | #html_theme_options = {} 115 | 116 | # Add any paths that contain custom themes here, relative to this directory. 117 | #html_theme_path = [] 118 | 119 | # The name for this set of Sphinx documents. If None, it defaults to 120 | # " v documentation". 121 | #html_title = None 122 | 123 | # A shorter title for the navigation bar. Default is the same as html_title. 124 | #html_short_title = None 125 | 126 | # The name of an image file (relative to this directory) to place at the top 127 | # of the sidebar. 128 | #html_logo = None 129 | 130 | # The name of an image file (within the static path) to use as favicon of the 131 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 132 | # pixels large. 133 | #html_favicon = None 134 | 135 | # Add any paths that contain custom static files (such as style sheets) here, 136 | # relative to this directory. They are copied after the builtin static files, 137 | # so a file named "default.css" will overwrite the builtin "default.css". 138 | html_static_path = ['_static'] 139 | 140 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 141 | # using the given strftime format. 142 | #html_last_updated_fmt = '%b %d, %Y' 143 | 144 | # If true, SmartyPants will be used to convert quotes and dashes to 145 | # typographically correct entities. 146 | #html_use_smartypants = True 147 | 148 | # Custom sidebar templates, maps document names to template names. 149 | #html_sidebars = {} 150 | 151 | # Additional templates that should be rendered to pages, maps page names to 152 | # template names. 153 | #html_additional_pages = {} 154 | 155 | # If false, no module index is generated. 156 | #html_domain_indices = True 157 | 158 | # If false, no index is generated. 159 | #html_use_index = True 160 | 161 | # If true, the index is split into individual pages for each letter. 162 | #html_split_index = False 163 | 164 | # If true, links to the reST sources are added to the pages. 165 | #html_show_sourcelink = True 166 | 167 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 168 | #html_show_sphinx = True 169 | 170 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 171 | #html_show_copyright = True 172 | 173 | # If true, an OpenSearch description file will be output, and all pages will 174 | # contain a tag referring to it. The value of this option must be the 175 | # base URL from which the finished HTML is served. 176 | #html_use_opensearch = '' 177 | 178 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 179 | #html_file_suffix = None 180 | 181 | # Output file base name for HTML help builder. 182 | htmlhelp_basename = 'gptoolsdoc' 183 | 184 | 185 | # -- Options for LaTeX output -------------------------------------------------- 186 | 187 | latex_elements = { 188 | # The paper size ('letterpaper' or 'a4paper'). 189 | #'papersize': 'letterpaper', 190 | 191 | # The font size ('10pt', '11pt' or '12pt'). 192 | #'pointsize': '10pt', 193 | 194 | # Additional stuff for the LaTeX preamble. 195 | 'preamble': r"""\hypersetup{bookmarksdepth=3} 196 | \setcounter{tocdepth}{3}""", 197 | } 198 | 199 | # Grouping the document tree into LaTeX files. List of tuples 200 | # (source start file, target name, title, author, documentclass [howto/manual]). 201 | latex_documents = [ 202 | ('index', 'gptools.tex', u'gptools Documentation', 203 | u'Mark Chilenski', 'manual'), 204 | ] 205 | 206 | # The name of an image file (relative to this directory) to place at the top of 207 | # the title page. 208 | #latex_logo = None 209 | 210 | # For "manual" documents, if this is true, then toplevel headings are parts, 211 | # not chapters. 212 | #latex_use_parts = False 213 | 214 | # If true, show page references after internal links. 215 | #latex_show_pagerefs = False 216 | 217 | # If true, show URL addresses after external links. 218 | #latex_show_urls = False 219 | 220 | # Documents to append as an appendix to all manuals. 221 | #latex_appendices = [] 222 | 223 | # If false, no module index is generated. 224 | #latex_domain_indices = True 225 | 226 | 227 | # -- Options for manual page output -------------------------------------------- 228 | 229 | # One entry per manual page. List of tuples 230 | # (source start file, name, description, authors, manual section). 231 | man_pages = [ 232 | ('index', 'gptools', u'gptools Documentation', 233 | [u'Mark Chilenski'], 1) 234 | ] 235 | 236 | # If true, show URL addresses after external links. 237 | #man_show_urls = False 238 | 239 | 240 | # -- Options for Texinfo output ------------------------------------------------ 241 | 242 | # Grouping the document tree into Texinfo files. List of tuples 243 | # (source start file, target name, title, author, 244 | # dir menu entry, description, category) 245 | texinfo_documents = [ 246 | ('index', 'gptools', u'gptools Documentation', 247 | u'Mark Chilenski', 'gptools', 'Gaussian process regression with support for arbitrary derivatives.', 248 | 'Miscellaneous'), 249 | ] 250 | 251 | # Documents to append as an appendix to all manuals. 252 | #texinfo_appendices = [] 253 | 254 | # If false, no module index is generated. 255 | #texinfo_domain_indices = True 256 | 257 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 258 | #texinfo_show_urls = 'footnote' 259 | 260 | # Mock up cython extensions so RTD doesn't choke: 261 | class Mock(object): 262 | __all__ = [] 263 | 264 | def __init__(self, *args, **kwargs): 265 | pass 266 | 267 | def __call__(self, *args, **kwargs): 268 | return Mock() 269 | 270 | @classmethod 271 | def __getattr__(cls, name): 272 | if name in ('__file__', '__path__'): 273 | return '/dev/null' 274 | elif name[0] == name[0].upper(): 275 | mockType = type(name, (), {}) 276 | mockType.__module__ = __name__ 277 | return mockType 278 | else: 279 | return Mock() 280 | 281 | MOCK_MODULES = ['gptools.kernel._matern'] 282 | for mod_name in MOCK_MODULES: 283 | sys.modules[mod_name] = Mock() 284 | -------------------------------------------------------------------------------- /docs/source/gptools.kernel.rst: -------------------------------------------------------------------------------- 1 | gptools.kernel package 2 | ====================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | gptools.kernel.core module 8 | -------------------------- 9 | 10 | .. automodule:: gptools.kernel.core 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | gptools.kernel.gibbs module 16 | --------------------------- 17 | 18 | .. automodule:: gptools.kernel.gibbs 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | gptools.kernel.matern module 24 | ---------------------------- 25 | 26 | .. automodule:: gptools.kernel.matern 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | gptools.kernel.noise module 32 | --------------------------- 33 | 34 | .. automodule:: gptools.kernel.noise 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | gptools.kernel.rational_quadratic module 40 | ---------------------------------------- 41 | 42 | .. automodule:: gptools.kernel.rational_quadratic 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | 47 | gptools.kernel.squared_exponential module 48 | ----------------------------------------- 49 | 50 | .. automodule:: gptools.kernel.squared_exponential 51 | :members: 52 | :undoc-members: 53 | :show-inheritance: 54 | 55 | gptools.kernel.warping module 56 | ----------------------------- 57 | 58 | .. automodule:: gptools.kernel.warping 59 | :members: 60 | :undoc-members: 61 | :show-inheritance: 62 | 63 | 64 | Module contents 65 | --------------- 66 | 67 | .. automodule:: gptools.kernel 68 | :members: 69 | :undoc-members: 70 | :show-inheritance: 71 | -------------------------------------------------------------------------------- /docs/source/gptools.rst: -------------------------------------------------------------------------------- 1 | gptools package 2 | =============== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | 9 | gptools.kernel 10 | 11 | Submodules 12 | ---------- 13 | 14 | gptools.error_handling module 15 | ----------------------------- 16 | 17 | .. automodule:: gptools.error_handling 18 | :members: 19 | :undoc-members: 20 | :show-inheritance: 21 | 22 | gptools.gaussian_process module 23 | ------------------------------- 24 | 25 | .. automodule:: gptools.gaussian_process 26 | :members: 27 | :undoc-members: 28 | :show-inheritance: 29 | 30 | gptools.gp_utils module 31 | ----------------------- 32 | 33 | .. automodule:: gptools.gp_utils 34 | :members: 35 | :undoc-members: 36 | :show-inheritance: 37 | 38 | gptools.mean module 39 | ------------------- 40 | 41 | .. automodule:: gptools.mean 42 | :members: 43 | :undoc-members: 44 | :show-inheritance: 45 | 46 | gptools.utils module 47 | -------------------- 48 | 49 | .. automodule:: gptools.utils 50 | :members: 51 | :undoc-members: 52 | :show-inheritance: 53 | 54 | 55 | Module contents 56 | --------------- 57 | 58 | .. automodule:: gptools 59 | :members: 60 | :undoc-members: 61 | :show-inheritance: 62 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. gptools documentation master file, created by 2 | sphinx-quickstart on Tue Sep 3 12:06:03 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | gptools: Gaussian processes with arbitrary derivative constraints and predictions 7 | ================================================================================= 8 | 9 | Source home: https://github.com/markchil/gptools 10 | 11 | Releases: https://pypi.python.org/pypi/gptools/ 12 | 13 | Installation is as simple as:: 14 | 15 | pip install gptools 16 | 17 | A comprehensive demo is provided at https://github.com/markchil/gptools/blob/master/demo/demo.py, with extensive comments showing how the code functions on real data (also hosted on the github). This should be consulted in parallel with this manual. 18 | 19 | Overview 20 | -------- 21 | 22 | :py:mod:`gptools` is a Python package that provides a convenient, powerful and extensible implementation of Gaussian process regression (GPR). Central to :py:mod:`gptools`' implementation is support for derivatives and their variances. Furthermore, the implementation supports the incorporation of arbitrary linearly transformed quantities into the GP. 23 | 24 | There are two key classes: 25 | 26 | * :py:class:`~gptools.gaussian_process.GaussianProcess` is the main class to represent a GP. 27 | * :py:class:`~gptools.kernel.core.Kernel` (and its many subclasses) represents a covariance kernel, and must be provided when constructing a :py:class:`~gptools.gaussian_process.GaussianProcess`. Separate kernels to describe the underlying signal and the noise are supported. 28 | 29 | A third class, :py:class:`~gptools.utils.JointPrior`, allows you to construct a hyperprior of arbitrary complexity to dictate how the hyperparameters are handled. 30 | 31 | Creating a Gaussian process is as simple as:: 32 | 33 | import gptools 34 | k = gptools.SquaredExponentialKernel() 35 | gp = gptools.GaussianProcess(k) 36 | 37 | But, the default bounds on the hyperparameters are very wide and can cause the optimizer/MCMC sampler to fail. So, it is usually a better idea to define the covariance kernel as:: 38 | 39 | k = gptools.SquaredExponentialKernel(param_bounds=[(0, 1e3), (0, 100)]) 40 | 41 | You will have to pick appropriate numbers by inspecting the typical range of your data. 42 | 43 | Furthermore, you can include an explicit mean function by passing 44 | the appropriate :py:class:`~gptools.mean.MeanFunction` instance into the `mu` keyword:: 45 | 46 | gp = gptools.GaussianProcess(k, mu=gptools.LinearMeanFunction()) 47 | 48 | This will enable you to perform inference (both empirical and full Bayes) for 49 | the hyperparameters of the mean function. Essentially, :py:mod:`gptools` can 50 | perform nonlinear Bayesian regression with a Gaussian process fit to the 51 | residuals. 52 | 53 | You then add the training data using the :py:meth:`~gptools.gaussian_process.GaussianProcess.add_data` method:: 54 | 55 | gp.add_data(x, y, err_y=stddev_y) 56 | 57 | Here, `err_y` is the :math:`1\sigma` uncertainty on the observations `y`. For exact values, simply omit this keyword. Adding a derivative observation is as simple as specifying the derivative order with the `n` keyword:: 58 | 59 | gp.add_data(0, 0, n=1) 60 | 61 | This will force the slope at :math:`x=0` to be exactly zero. Quantities that represent an arbitrary linear transformation of the "basic" observations can be added by specifying the `T` keyword:: 62 | 63 | gp.add_data(x, y, T=T) 64 | 65 | This will add the value(s) :math:`y = T Y(x)` to the training data, where here :math:`Y` represents the "basic" (untransformed) observations and :math:`y` represents the transformed observations. This also supports the `err_y` and `n` keywords. Here, `err_y` is the error on the transformed quantity :math:`y`. `n` applies to the latent variables :math:`Y(x)`. 66 | 67 | Once the GP has been populated with training data, there are two approaches supported to handle the hyperparameters. 68 | 69 | The simplest approach is to use an empirical Bayes approach and compute the maximum a posteriori (MAP) estimate. This is accomplished using the :py:meth:`~gptools.gaussian_process.GaussianProcess.optimize_hyperparameters` method of the :py:class:`~gptools.gaussian_process.GaussianProcess` instance:: 70 | 71 | gp.optimize_hyperparameters() 72 | 73 | This will randomly start the optimizer at points distributed according to the hyperprior several times in order to ensure that the global maximum is obtained. If you have a machine with multiple cores, these random starts will be performed in parallel. You can set the number of starts using the `random_starts` keyword, and you can set the number of processes used using the `num_proc` keyword. 74 | 75 | For a more complete accounting of the uncertainties in the model, you can choose to use a fully Bayesian approach by using Markov chain Monte Carlo (MCMC) techniques to produce samples of the hyperposterior. The samples are produced directly with :py:meth:`~gptools.gaussian_process.GaussianProcess.sample_hyperparameter_posterior`, though it will typically be more convenient to simply call :py:meth:`~gptools.gaussian_process.GaussianProcess.predict` with the `use_MCMC` keyword set to True. 76 | 77 | In order to make predictions, use the :py:meth:`~gptools.gaussian_process.GaussianProcess.predict` method:: 78 | 79 | y_star, err_y_star = gp.predict(x_star) 80 | 81 | By default, the mean and standard deviation of the GP posterior are returned. To compute only the mean and save some time, set the `return_std` keyword to False. To make predictions of derivatives, set the `n` keyword. To make a prediction of a linearly transformed quantity, set the `output_transform` keyword. 82 | 83 | For a convenient wrapper for applying :py:mod:`gptools` to multivariate data, see :py:mod:`profiletools` at https://github.com/markchil/profiletools 84 | 85 | Kernels 86 | ------- 87 | 88 | A number of kernels are provided to allow many types of data to be fit: 89 | 90 | * :py:class:`~gptools.kernel.noise.DiagonalNoiseKernel` implements homoscedastic noise. The noise is tied to a specific derivative order. This allows you to, for instance, have noise on your observations but have noiseless derivative constraints, or to have different noise levels for observations and derivatives. Note that you can also specify potentially heteroscedastic noise explicitly when adding data to the process. 91 | * :py:class:`~gptools.kernel.squared_exponential.SquaredExponentialKernel` implements the SE kernel which is infinitely differentiable. 92 | * :py:class:`~gptools.kernel.matern.MaternKernel` implements the entire Matern class of covariance functions, which are characterized by a hyperparameter :math:`\nu`. A process having the Matern kernel is only mean-square differentiable for derivative order :math:`n<\nu`. Note that this class does not support arbitrary derivatives at this point. If you need this feature, try using :py:class:`~gptools.kernel.matern.MaternKernelArb`, but note that this is very slow! 93 | * :py:class:`~gptools.kernel.matern.Matern52Kernel` implements a specialized Matern kernel with :math:`\nu=\frac{5}{2}` which efficiently supports 0th and 1st derivatives. 94 | * :py:class:`~gptools.kernel.rational_quadratic.RationalQuadraticKernel` implements the rational quadratic kernel, which is a scale mixture over SE kernels. 95 | * :py:class:`~gptools.kernel.gibbs.GibbsKernel1d` and its subclasses implements the Gibbs kernel, which is a nonstationary form of the SE kernel. 96 | * :py:class:`~gptools.kernel.core.MaskedKernel` creates a kernel that only operates on a subset of dimensions. Use this along with the sum and product operations to create kernels that encode different properties in different dimensions. 97 | * :py:class:`~gptools.kernel.core.ArbitraryKernel` creates a kernel with an arbitrary covariance function and computes the derivatives as needed using :py:mod:`mpmath` to perform numerical differentiation. Naturally, this is very slow but is useful to let you explore the properties of arbitrary kernels without having to write a complete implementation. 98 | 99 | In most cases, these kernels have been constructed in a way to allow inputs of arbitrary dimension. Each dimension has a length scale hyperparameter that can be separately optimized over or held fixed. Arbitrary derivatives with respect to each dimension can be taken, including computation of the covariance for those observations. 100 | 101 | Other kernels can be implemented by extending the :py:class:`~gptools.kernel.core.Kernel` class. Furthermore, kernels may be added or multiplied together to yield a new, valid kernel. 102 | 103 | Notes 104 | ----- 105 | 106 | :py:mod:`gptools` has been developed and tested on Python 2.7 and scipy 0.14.0. It may work just as well on other versions, but has not been tested. 107 | 108 | If you find this software useful, please be sure to cite it: 109 | 110 | M.A. Chilenski et al. 2015 Nucl. Fusion 55 023012 111 | 112 | http://stacks.iop.org/0029-5515/55/023012 113 | 114 | Contents 115 | -------- 116 | 117 | .. toctree:: 118 | :maxdepth: 4 119 | 120 | gptools 121 | 122 | Indices and tables 123 | ================== 124 | 125 | * :ref:`genindex` 126 | * :ref:`modindex` 127 | * :ref:`search` 128 | 129 | -------------------------------------------------------------------------------- /docs/source/modules.rst: -------------------------------------------------------------------------------- 1 | gptools 2 | ======= 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | gptools 8 | -------------------------------------------------------------------------------- /docs/source/readthedocs-pip-requirements.txt: -------------------------------------------------------------------------------- 1 | cython 2 | numpy 3 | scipy 4 | mpmath 5 | numpydoc 6 | 7 | -------------------------------------------------------------------------------- /gptools/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Mark Chilenski 2 | # This program is distributed under the terms of the GNU General Purpose License (GPL). 3 | # Refer to http://www.gnu.org/licenses/gpl.txt 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | """:py:mod:`gptools` - Gaussian process regression with support for arbitrary derivatives 19 | """ 20 | 21 | from __future__ import division 22 | 23 | __version__ = '0.2.4_dev' 24 | 25 | from .gaussian_process import * 26 | from .error_handling import * 27 | from .kernel import * 28 | from .utils import * 29 | from .gp_utils import * 30 | from .mean import * -------------------------------------------------------------------------------- /gptools/error_handling.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Mark Chilenski 2 | # This program is distributed under the terms of the GNU General Purpose License (GPL). 3 | # Refer to http://www.gnu.org/licenses/gpl.txt 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | """Contains exceptions specific to the :py:mod:`gptools` package. 19 | """ 20 | 21 | from __future__ import division 22 | 23 | class GPArgumentError(Exception): 24 | """Exception class raised when an incorrect combination of keyword arguments is given. 25 | """ 26 | pass 27 | 28 | class GPImpossibleParamsError(Exception): 29 | """Exception class raised when parameters are not possible. 30 | """ 31 | pass -------------------------------------------------------------------------------- /gptools/gp_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Mark Chilenski 2 | # This program is distributed under the terms of the GNU General Purpose License (GPL). 3 | # Refer to http://www.gnu.org/licenses/gpl.txt 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | """Provides convenient utilities for working with the classes and results from :py:mod:`gptools`. 19 | 20 | This module specifically contains utilities that need to interact directly with 21 | the GaussianProcess object, and hence can present circular import problems when 22 | incorporated in the main utils submodule. 23 | """ 24 | 25 | from __future__ import division 26 | 27 | from .gaussian_process import GaussianProcess 28 | from .error_handling import GPArgumentError 29 | 30 | import multiprocessing 31 | try: 32 | import matplotlib.pyplot as plt 33 | import matplotlib.widgets as mplw 34 | import matplotlib.gridspec as mplgs 35 | except ImportError: 36 | import warnings 37 | warnings.warn( 38 | "Could not import matplotlib. slice_plot will not be available.", 39 | ImportWarning 40 | ) 41 | import itertools 42 | import scipy 43 | import copy 44 | 45 | def parallel_compute_ll_matrix(gp, bounds, num_pts, num_proc=None): 46 | """Compute matrix of the log likelihood over the parameter space in parallel. 47 | 48 | Parameters 49 | ---------- 50 | bounds : 2-tuple or list of 2-tuples with length equal to the number of free parameters 51 | Bounds on the range to use for each of the parameters. If a single 52 | 2-tuple is given, it will be used for each of the parameters. 53 | num_pts : int or list of ints with length equal to the number of free parameters 54 | The number of points to use for each parameters. If a single int is 55 | given, it will be used for each of the parameters. 56 | num_proc : Positive int or None, optional 57 | Number of processes to run the parallel computation with. If set to 58 | None, ALL available cores are used. Default is None (use all available 59 | cores). 60 | 61 | Returns 62 | ------- 63 | ll_vals : array 64 | The log likelihood for each of the parameter possibilities. 65 | param_vals : list of array 66 | The parameter values used. 67 | """ 68 | if num_proc is None: 69 | num_proc = multiprocessing.cpu_count() 70 | 71 | present_free_params = gp.free_params 72 | 73 | bounds = scipy.atleast_2d(scipy.asarray(bounds, dtype=float)) 74 | if bounds.shape[1] != 2: 75 | raise ValueError("Argument bounds must have shape (n, 2)!") 76 | # If bounds is a single tuple, repeat it for each free parameter: 77 | if bounds.shape[0] == 1: 78 | bounds = scipy.tile(bounds, (len(present_free_params), 1)) 79 | # If num_pts is a single value, use it for all of the parameters: 80 | try: 81 | iter(num_pts) 82 | except TypeError: 83 | num_pts = num_pts * scipy.ones(bounds.shape[0], dtype=int) 84 | else: 85 | num_pts = scipy.asarray(num_pts, dtype=int) 86 | if len(num_pts) != len(present_free_params): 87 | raise ValueError("Length of num_pts must match the number of free parameters of kernel!") 88 | 89 | # Form arrays to evaluate parameters over: 90 | param_vals = [] 91 | for k in range(0, len(present_free_params)): 92 | param_vals.append(scipy.linspace(bounds[k, 0], bounds[k, 1], num_pts[k])) 93 | 94 | pv_cases = list() 95 | gp_cases = list() 96 | num_pts_cases = list() 97 | for k in range(0, len(param_vals[0])): 98 | specific_param_vals = list(param_vals) 99 | specific_param_vals[0] = param_vals[0][k] 100 | pv_cases.append(specific_param_vals) 101 | 102 | gp_cases += [copy.deepcopy(gp)] 103 | 104 | num_pts_cases.append(num_pts) 105 | 106 | pool = multiprocessing.Pool(processes=num_proc) 107 | try: 108 | vals = scipy.asarray( 109 | pool.map( 110 | _compute_ll_matrix_wrapper, 111 | zip(gp_cases, pv_cases, num_pts_cases) 112 | ) 113 | ) 114 | finally: 115 | pool.close() 116 | 117 | return (vals, param_vals) 118 | 119 | def _compute_ll_matrix_wrapper(gppv): 120 | """Helper wrapper function to enable use of multiprocessing.map. 121 | 122 | Parameters 123 | ---------- 124 | gppv : 3-tuple 125 | (`gp`, `param_vals`, `num_pts`) 126 | 127 | Returns 128 | ------- 129 | vals : array 130 | Log likelihood evaluated at the parameters specified in `param_vals`. 131 | """ 132 | return gppv[0]._compute_ll_matrix(1, gppv[1], gppv[2]) 133 | 134 | def slice_plot(*args, **kwargs): 135 | """Constructs a plot that lets you look at slices through a multidimensional array. 136 | 137 | Parameters 138 | ---------- 139 | vals : array, (`M`, `D`, `P`, ...) 140 | Multidimensional array to visualize. 141 | x_vals_1 : array, (`M`,) 142 | Values along the first dimension. 143 | x_vals_2 : array, (`D`,) 144 | Values along the second dimension. 145 | x_vals_3 : array, (`P`,) 146 | Values along the third dimension. 147 | 148 | **...and so on. At least four arguments must be provided.** 149 | 150 | names : list of strings, optional 151 | Names for each of the parameters at hand. If None, sequential numerical 152 | identifiers will be used. Length must be equal to the number of 153 | dimensions of `vals`. Default is None. 154 | n : Positive int, optional 155 | Number of contours to plot. Default is 100. 156 | 157 | Returns 158 | ------- 159 | f : :py:class:`Figure` 160 | The Matplotlib figure instance created. 161 | 162 | Raises 163 | ------ 164 | GPArgumentError 165 | If the number of arguments is less than 4. 166 | """ 167 | names = kwargs.get('names', None) 168 | n = kwargs.get('n', 100) 169 | num_axes = len(args) - 1 170 | if num_axes < 3: 171 | raise GPArgumentError("Must pass at least four arguments to slice_plot!") 172 | if num_axes != args[0].ndim: 173 | raise GPArgumentError("Number of dimensions of the first argument " 174 | "must match the number of additional arguments " 175 | "provided!") 176 | if names is None: 177 | names = [str(k) for k in range(2, num_axes)] 178 | f = plt.figure() 179 | height_ratios = [8] 180 | height_ratios += (num_axes - 2) * [1] 181 | gs = mplgs.GridSpec(num_axes - 2 + 1, 2, height_ratios=height_ratios, width_ratios=[8, 1]) 182 | 183 | a_main = f.add_subplot(gs[0, 0]) 184 | a_cbar = f.add_subplot(gs[0, 1]) 185 | a_sliders = [] 186 | for idx in range(0, num_axes - 2): 187 | a_sliders.append(f.add_subplot(gs[idx+1, :])) 188 | 189 | title = f.suptitle("") 190 | 191 | def update(val): 192 | """Update the slice shown. 193 | """ 194 | a_main.clear() 195 | a_cbar.clear() 196 | idxs = [int(slider.val) for slider in sliders] 197 | vals = [args[k + 3][idxs[k]] for k in range(0, num_axes - 2)] 198 | descriptions = tuple(itertools.chain.from_iterable(itertools.izip(names[2:], vals))) 199 | fmt = "Slice" + (num_axes - 2) * ", {:s}: {:f}" 200 | title.set_text(fmt.format(descriptions)) 201 | 202 | a_main.set_xlabel(names[1]) 203 | a_main.set_ylabel(names[0]) 204 | cs = a_main.contour( 205 | args[2], 206 | args[1], 207 | args[0][scipy.s_[:, :] + tuple(idxs)].squeeze(), 208 | n, 209 | vmin=args[0].min(), 210 | vmax=args[1].max() 211 | ) 212 | cbar = f.colorbar(cs, cax=a_cbar) 213 | cbar.set_label("LL") 214 | 215 | f.canvas.draw() 216 | 217 | idxs_0 = (num_axes - 2) * [0] 218 | sliders = [] 219 | for idx in range(0, num_axes - 2): 220 | sliders.append( 221 | mplw.Slider( 222 | a_sliders[idx], 223 | '%s index' % names[idx + 2], 224 | 0, 225 | len(args[idx + 3]) - 1, 226 | valinit=idxs_0[idx], 227 | valfmt='%d' 228 | ) 229 | ) 230 | sliders[-1].on_changed(update) 231 | 232 | update(idxs_0) 233 | 234 | f.canvas.mpl_connect('key_press_event', lambda evt: arrow_respond(sliders[0], evt)) 235 | 236 | return f 237 | 238 | def arrow_respond(slider, event): 239 | """Event handler for arrow key events in plot windows. 240 | 241 | Pass the slider object to update as a masked argument using a lambda function:: 242 | 243 | lambda evt: arrow_respond(my_slider, evt) 244 | 245 | Parameters 246 | ---------- 247 | slider : Slider instance associated with this handler. 248 | event : Event to be handled. 249 | """ 250 | if event.key == 'right': 251 | slider.set_val(min(slider.val + 1, slider.valmax)) 252 | elif event.key == 'left': 253 | slider.set_val(max(slider.val - 1, slider.valmin)) 254 | -------------------------------------------------------------------------------- /gptools/kernel/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Mark Chilenski 2 | # This program is distributed under the terms of the GNU General Purpose License (GPL). 3 | # Refer to http://www.gnu.org/licenses/gpl.txt 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | """Subpackage containing a variety of covariance kernels and associated helpers. 19 | """ 20 | 21 | from __future__ import division 22 | 23 | from .core import * 24 | from .matern import * 25 | from .noise import * 26 | from .squared_exponential import * 27 | from .rational_quadratic import * 28 | from .gibbs import * 29 | from .warping import * -------------------------------------------------------------------------------- /gptools/kernel/_matern.pyx: -------------------------------------------------------------------------------- 1 | import cython 2 | import numpy as np 3 | from libc.stdint cimport int32_t 4 | 5 | cdef extern from "matern.h": 6 | double matern52(double *xi, double *xj, 7 | int32_t* ni, int32_t* nj, 8 | int32_t d, double* var) nogil 9 | 10 | 11 | @cython.boundscheck(False) 12 | @cython.wraparound(False) 13 | @cython.cdivision(True) 14 | cpdef _matern52(double[:, ::1] Xi, double[:, ::1] Xj, 15 | int32_t[:, ::1] ni, int32_t[:, ::1] nj, 16 | double[::1] var): 17 | 18 | cdef int i, d, n 19 | n = Xi.shape[0] 20 | d = Xi.shape[1] 21 | if not (n == len(Xi) == len(Xj) == len(ni) == len(nj)): 22 | raise ValueError("Lengths don't match") 23 | if not (d == Xi.shape[1] == Xj.shape[1] == ni.shape[1] == nj.shape[1] == len(var)): 24 | raise ValueError("Widths don't match") 25 | 26 | cdef double[::1] out = np.zeros(n, dtype=np.float64) 27 | 28 | with nogil: 29 | for i in range(n): 30 | out[i] = matern52(&Xi[i, 0], &Xj[i, 0], &ni[i, 0], &nj[i, 0], d, &var[0]) 31 | 32 | return out 33 | -------------------------------------------------------------------------------- /gptools/kernel/include/matern.h: -------------------------------------------------------------------------------- 1 | #ifndef MATERN_KERNEL_H_ 2 | #define MATERN_KERNEL_H_ 3 | #ifdef _MSC_VER 4 | typedef __int32 int32_t; 5 | #else 6 | #include 7 | #endif 8 | 9 | /** 10 | * Evaluate the Matern 5/2 kernel between a pair of points xi, xj in R^d. 11 | * 12 | * Parameters 13 | * ---------- 14 | * xi : array, (d,) 15 | * xj : array, (d,) 16 | * ni : array, (d,) 17 | * The derivative orders with respect to xi 18 | * nj : array, (d,) 19 | * The derivative orders with respect to xj 20 | * d : int 21 | * var : array, (d,) 22 | * The squared length scale (variance) in each direction 23 | */ 24 | double matern52(const double *xi, const double *xj, 25 | const int32_t* ni, const int32_t* nj, 26 | int32_t d, const double* ls); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /gptools/kernel/noise.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Mark Chilenski 2 | # This program is distributed under the terms of the GNU General Purpose License (GPL). 3 | # Refer to http://www.gnu.org/licenses/gpl.txt 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | """Provides classes for implementing uncorrelated noise. 19 | """ 20 | 21 | from __future__ import division 22 | 23 | from .core import Kernel 24 | 25 | import scipy 26 | 27 | class DiagonalNoiseKernel(Kernel): 28 | """Kernel that has constant, independent noise (i.e., a diagonal kernel). 29 | 30 | Parameters 31 | ---------- 32 | num_dim : positive int 33 | Number of dimensions of the input data. 34 | initial_noise : float, optional 35 | Initial value for the noise standard deviation. Default value is None 36 | (noise gets set to 1). 37 | fixed_noise : bool, optional 38 | Whether or not the noise is taken to be fixed when optimizing the log 39 | likelihood. Default is False (noise is not fixed). 40 | noise_bound : 2-tuple, optional 41 | The bounds for the noise when optimizing the log likelihood with 42 | :py:func:`scipy.optimize.minimize`. Must be of the form 43 | (`lower`, `upper`). Set a given entry to None to put no bound on 44 | that side. Default is None, which gets set to (0, None). 45 | n : non-negative int or tuple of non-negative ints with length equal to `num_dim`, optional 46 | Indicates which derivative this noise is with respect to. Default is 0 47 | (noise applies to value). 48 | hyperprior : callable, optional 49 | Function that returns the prior log-density for a possible value of 50 | noise when called. Must also have an attribute called :py:attr:`bounds` 51 | that is the bounds on the noise and a method called 52 | :py:meth:`random_draw` that yields a random draw. Default behavior is 53 | to assign a uniform prior. 54 | """ 55 | def __init__(self, num_dim=1, initial_noise=None, fixed_noise=False, noise_bound=None, n=0, hyperprior=None): 56 | try: 57 | iter(n) 58 | except TypeError: 59 | self.n = n * scipy.ones(num_dim, dtype=int) 60 | else: 61 | if len(n) != num_dim: 62 | raise ValueError("Length of n must be equal to num_dim!") 63 | self.n = scipy.asarray(n, dtype=int) 64 | if initial_noise is not None: 65 | initial_noise = [initial_noise] 66 | if noise_bound is not None: 67 | noise_bound = [noise_bound] 68 | super(DiagonalNoiseKernel, self).__init__(num_dim=num_dim, 69 | num_params=1, 70 | initial_params=initial_noise, 71 | fixed_params=[True] if fixed_noise else None, 72 | param_bounds=noise_bound, 73 | hyperprior=hyperprior, 74 | param_names=[r'\sigma_n']) 75 | 76 | def __call__(self, Xi, Xj, ni, nj, hyper_deriv=None, symmetric=False): 77 | """Evaluate the covariance between points `Xi` and `Xj` with derivative order `ni`, `nj`. 78 | 79 | Parameters 80 | ---------- 81 | Xi : :py:class:`Matrix` or other Array-like, (`M`, `D`) 82 | `M` inputs with dimension `D`. 83 | Xj : :py:class:`Matrix` or other Array-like, (`M`, `D`) 84 | `M` inputs with dimension `D`. 85 | ni : :py:class:`Matrix` or other Array-like, (`M`, `D`) 86 | `M` derivative orders for set `i`. 87 | nj : :py:class:`Matrix` or other Array-like, (`M`, `D`) 88 | `M` derivative orders for set `j`. 89 | hyper_deriv : Non-negative int or None, optional 90 | The index of the hyperparameter to compute the first derivative 91 | with respect to. Since this kernel only has one hyperparameter, 0 92 | is the only valid value. If None, no derivatives are taken. Default 93 | is None (no hyperparameter derivatives). 94 | symmetric : bool, optional 95 | Whether or not the input `Xi`, `Xj` are from a symmetric matrix. 96 | Default is False. 97 | 98 | Returns 99 | ------- 100 | Kij : :py:class:`Array`, (`M`,) 101 | Covariances for each of the `M` `Xi`, `Xj` pairs. 102 | """ 103 | if symmetric: 104 | val = self.params[0]**2 * scipy.asarray(((Xi == Xj) & (ni == self.n) & (nj == self.n)).all(axis=1), dtype=float).flatten() 105 | if hyper_deriv is None: 106 | return val 107 | else: 108 | return 2.0 * val / self.params[hyper_deriv] 109 | else: 110 | return scipy.zeros(Xi.shape[0]) 111 | 112 | class ZeroKernel(DiagonalNoiseKernel): 113 | """Kernel that always evaluates to zero, used as the default noise kernel. 114 | 115 | Parameters 116 | ---------- 117 | num_dim : positive int 118 | The number of dimensions of the inputs. 119 | """ 120 | def __init__(self, num_dim=1): 121 | super(ZeroKernel, self).__init__(num_dim=num_dim, initial_noise=0.0, fixed_noise=True) 122 | 123 | def __call__(self, Xi, Xj, ni, nj, hyper_deriv=None, symmetric=False): 124 | """Return zeros the same length as the input Xi. 125 | 126 | Ignores all other arguments. 127 | 128 | Parameters 129 | ---------- 130 | Xi : :py:class:`Matrix` or other Array-like, (`M`, `D`) 131 | `M` inputs with dimension `D`. 132 | Xj : :py:class:`Matrix` or other Array-like, (`M`, `D`) 133 | `M` inputs with dimension `D`. 134 | ni : :py:class:`Matrix` or other Array-like, (`M`, `D`) 135 | `M` derivative orders for set `i`. 136 | nj : :py:class:`Matrix` or other Array-like, (`M`, `D`) 137 | `M` derivative orders for set `j`. 138 | hyper_deriv : Non-negative int or None, optional 139 | The index of the hyperparameter to compute the first derivative 140 | with respect to. Since this kernel only has one hyperparameter, 0 141 | is the only valid value. If None, no derivatives are taken. Default 142 | is None (no hyperparameter derivatives). 143 | symmetric : bool, optional 144 | Whether or not the input `Xi`, `Xj` are from a symmetric matrix. 145 | Default is False. 146 | 147 | Returns 148 | ------- 149 | Kij : :py:class:`Array`, (`M`,) 150 | Covariances for each of the `M` `Xi`, `Xj` pairs. 151 | """ 152 | return scipy.zeros(Xi.shape[0], dtype=float) 153 | -------------------------------------------------------------------------------- /gptools/kernel/rational_quadratic.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Mark Chilenski 2 | # This program is distributed under the terms of the GNU General Purpose License (GPL). 3 | # Refer to http://www.gnu.org/licenses/gpl.txt 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | """Provides the :py:class:`RationalQuadraticKernel` class which implements the anisotropic rational quadratic (RQ) kernel. 19 | """ 20 | 21 | from __future__ import division 22 | 23 | from .core import ChainRuleKernel 24 | from ..utils import fixed_poch 25 | 26 | import scipy 27 | import scipy.special 28 | import scipy.misc 29 | 30 | class RationalQuadraticKernel(ChainRuleKernel): 31 | r"""Rational quadratic (RQ) covariance kernel. Supports arbitrary derivatives. 32 | 33 | The RQ kernel has the following hyperparameters, always referenced 34 | in the order listed: 35 | 36 | = ===== ===================================== 37 | 0 sigma prefactor. 38 | 1 alpha order of kernel. 39 | 2 l1 length scale for the first dimension. 40 | 3 l2 ...and so on for all dimensions. 41 | = ===== ===================================== 42 | 43 | The kernel is defined as: 44 | 45 | .. math:: 46 | 47 | k_{RQ} = \sigma^2 \left(1 + \frac{1}{2\alpha} \sum_i\frac{\tau_i^2}{l_i^2}\right)^{-\alpha} 48 | 49 | Parameters 50 | ---------- 51 | num_dim : int 52 | Number of dimensions of the input data. Must be consistent 53 | with the `X` and `Xstar` values passed to the 54 | :py:class:`~gptools.gaussian_process.GaussianProcess` you 55 | wish to use the covariance kernel with. 56 | **kwargs 57 | All keyword parameters are passed to :py:class:`~gptools.kernel.core.ChainRuleKernel`. 58 | 59 | Raises 60 | ------ 61 | ValueError 62 | If `num_dim` is not a positive integer or the lengths of 63 | the input vectors are inconsistent. 64 | GPArgumentError 65 | If `fixed_params` is passed but `initial_params` is not. 66 | """ 67 | def __init__(self, num_dim=1, **kwargs): 68 | param_names = [r'\sigma_f', r'\alpha'] + ['l_{:d}'.format(i + 1) for i in range(0, num_dim)] 69 | super(RationalQuadraticKernel, self).__init__(num_dim=num_dim, 70 | num_params=num_dim + 2, 71 | param_names=param_names, 72 | **kwargs) 73 | 74 | def _compute_k(self, tau): 75 | r"""Evaluate the kernel directly at the given values of `tau`. 76 | 77 | Parameters 78 | ---------- 79 | tau : :py:class:`Matrix`, (`M`, `D`) 80 | `M` inputs with dimension `D`. 81 | 82 | Returns 83 | ------- 84 | k : :py:class:`Array`, (`M`,) 85 | :math:`k(\tau)` (less the :math:`\sigma^2` prefactor). 86 | """ 87 | y = self._compute_y(tau) 88 | return y**(-self.params[1]) 89 | 90 | def _compute_y(self, tau, return_r2l2=False): 91 | r"""Covert tau to :math:`y = 1 + \frac{1}{2\alpha} \sum_i \frac{\tau_i^2}{l_i^2}`. 92 | 93 | Parameters 94 | ---------- 95 | tau : :py:class:`Matrix`, (`M`, `D`) 96 | `M` inputs with dimension `D`. 97 | return_r2l2 : bool, optional 98 | Set to True to return a tuple of (`y`, `r2l2`). Default is False 99 | (only return `y`). 100 | 101 | Returns 102 | ------- 103 | y : :py:class:`Array`, (`M`,) 104 | Inner argument of function. 105 | r2l2 : :py:class:`Array`, (`M`,) 106 | Anisotropically scaled distances. Only returned if `return_r2l2` 107 | is True. 108 | """ 109 | r2l2 = self._compute_r2l2(tau) 110 | y = 1.0 + 1.0 / (2.0 * self.params[1]) * r2l2 111 | if return_r2l2: 112 | return (y, r2l2) 113 | else: 114 | return y 115 | 116 | def _compute_dk_dy(self, y, n): 117 | """Evaluate the derivative of the outer form of the RQ kernel. 118 | 119 | Parameters 120 | ---------- 121 | y : :py:class:`Array`, (`M`,) 122 | `M` inputs to evaluate at. 123 | n : non-negative scalar int 124 | Order of derivative to compute. 125 | 126 | Returns 127 | ------- 128 | dk_dy : :py:class:`Array`, (`M`,) 129 | Specified derivative at specified locations. 130 | """ 131 | p = fixed_poch(1.0 - self.params[1] - n, n) 132 | return p * y**(-self.params[1] - n) 133 | 134 | def _compute_dy_dtau(self, tau, b, r2l2): 135 | r"""Evaluate the derivative of the inner argument of the Matern kernel. 136 | 137 | Uses Faa di Bruno's formula to take the derivative of 138 | 139 | .. math:: 140 | 141 | y = 1 + \frac{1}{2\alpha}\sum_i(\tau_i^2/l_i^2)}`. 142 | 143 | Parameters 144 | ---------- 145 | tau : :py:class:`Matrix`, (`M`, `D`) 146 | `M` inputs with dimension `D`. 147 | b : :py:class:`Array`, (`P`,) 148 | Block specifying derivatives to be evaluated. 149 | r2l2 : :py:class:`Array`, (`M`,) 150 | Precomputed anisotropically scaled distance. 151 | 152 | Returns 153 | ------- 154 | dy_dtau : :py:class:`Array`, (`M`,) 155 | Specified derivative at specified locations. 156 | """ 157 | if len(b) == 0: 158 | return self._compute_y(tau) 159 | elif len(b) == 1: 160 | return 1.0 / self.params[1] * tau[:, b[0]] / (self.params[2 + b[0]])**2.0 161 | elif len(b) == 2 and b[0] == b[1]: 162 | return 1.0 / (self.params[1] * (self.params[2 + b[0]])**2.0) 163 | else: 164 | return scipy.zeros_like(r2l2) 165 | -------------------------------------------------------------------------------- /gptools/kernel/squared_exponential.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Mark Chilenski 2 | # This program is distributed under the terms of the GNU General Purpose 3 | # License (GPL). 4 | # Refer to http://www.gnu.org/licenses/gpl.txt 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | """Provides the :py:class:`SquaredExponentialKernel` class that implements the 20 | anisotropic SE kernel. 21 | """ 22 | 23 | from __future__ import division 24 | 25 | from .core import Kernel 26 | 27 | import scipy 28 | import scipy.special 29 | 30 | 31 | class SquaredExponentialKernel(Kernel): 32 | r"""Squared exponential covariance kernel. Supports arbitrary derivatives. 33 | 34 | Supports derivatives with respect to the hyperparameters. 35 | 36 | The squared exponential has the following hyperparameters, always 37 | referenced in the order listed: 38 | 39 | = ===== ==================================== 40 | 0 sigma prefactor on the SE 41 | 1 l1 length scale for the first dimension 42 | 2 l2 ...and so on for all dimensions 43 | = ===== ==================================== 44 | 45 | The kernel is defined as: 46 | 47 | .. math:: 48 | 49 | k_{SE} = \sigma^2 \exp\left(-\frac{1}{2}\sum_i\frac{\tau_i^2}{l_i^2}\right) 50 | 51 | Parameters 52 | ---------- 53 | num_dim : int 54 | Number of dimensions of the input data. Must be consistent 55 | with the `X` and `Xstar` values passed to the 56 | :py:class:`~gptools.gaussian_process.GaussianProcess` you 57 | wish to use the covariance kernel with. 58 | **kwargs 59 | All keyword parameters are passed to 60 | :py:class:`~gptools.kernel.core.Kernel`. 61 | 62 | Raises 63 | ------ 64 | ValueError 65 | If `num_dim` is not a positive integer or the lengths of 66 | the input vectors are inconsistent. 67 | 68 | GPArgumentError 69 | If `fixed_params` is passed but `initial_params` is not. 70 | """ 71 | def __init__(self, num_dim=1, **kwargs): 72 | param_names = [r'\sigma_f'] + [ 73 | 'l_{:d}'.format(i + 1,) for i in range(0, num_dim) 74 | ] 75 | super(SquaredExponentialKernel, self).__init__( 76 | num_dim=num_dim, 77 | num_params=num_dim + 1, 78 | param_names=param_names, 79 | **kwargs 80 | ) 81 | 82 | def __call__(self, Xi, Xj, ni, nj, hyper_deriv=None, symmetric=False): 83 | """Evaluate the covariance between points `Xi` and `Xj` with derivative 84 | order `ni`, `nj`. 85 | 86 | Parameters 87 | ---------- 88 | Xi : :py:class:`Matrix` or other Array-like, (`M`, `D`) 89 | `M` inputs with dimension `D`. 90 | Xj : :py:class:`Matrix` or other Array-like, (`M`, `D`) 91 | `M` inputs with dimension `D`. 92 | ni : :py:class:`Matrix` or other Array-like, (`M`, `D`) 93 | `M` derivative orders for set `i`. 94 | nj : :py:class:`Matrix` or other Array-like, (`M`, `D`) 95 | `M` derivative orders for set `j`. 96 | hyper_deriv : Non-negative int or None, optional 97 | The index of the hyperparameter to compute the first derivative 98 | with respect to. If None, no derivatives are taken. Default is None 99 | (no hyperparameter derivatives). Hyperparameter derivatives are not 100 | support for `n` > 0 at this time. 101 | symmetric : bool, optional 102 | Whether or not the input `Xi`, `Xj` are from a symmetric matrix. 103 | Default is False. 104 | 105 | Returns 106 | ------- 107 | Kij : :py:class:`Array`, (`M`,) 108 | Covariances for each of the `M` `Xi`, `Xj` pairs. 109 | """ 110 | only_first_order = ( 111 | (scipy.asarray(ni, dtype=scipy.intc) == 0).all() and 112 | (scipy.asarray(nj, dtype=scipy.intc) == 0).all() 113 | ) 114 | tau = scipy.asarray(Xi - Xj, dtype=scipy.double) 115 | r2l2, l_mat = self._compute_r2l2(tau, return_l=True) 116 | k = self.params[0] ** 2 * scipy.exp(-r2l2 / 2.0) 117 | if not only_first_order: 118 | # Account for derivatives: 119 | # Get total number of differentiations: 120 | n_tot_j = scipy.asarray( 121 | scipy.sum(nj, axis=1), dtype=scipy.intc 122 | ).flatten() 123 | n_combined = scipy.asarray(ni + nj, dtype=scipy.intc) 124 | # Compute factor from the dtau_d/dx_d_j terms in the chain rule: 125 | j_chain_factors = (-1.0) ** (n_tot_j) 126 | # Compute Hermite polynomial factor: 127 | hermite_factors = ( 128 | (-1.0 / (scipy.sqrt(2.0) * l_mat)) ** (n_combined) * 129 | scipy.special.eval_hermite( 130 | n_combined, tau / (scipy.sqrt(2.0) * l_mat) 131 | ) 132 | ) 133 | # Handle length scale hyperparameter derivatives: 134 | if hyper_deriv is not None and hyper_deriv > 0: 135 | t = (tau[:, hyper_deriv - 1]) ** 2.0 / \ 136 | (self.params[hyper_deriv]) ** 3.0 137 | mask = n_combined[:, hyper_deriv - 1] > 0 138 | t[mask] -= n_combined[mask, hyper_deriv - 1] / \ 139 | self.params[hyper_deriv] 140 | mask = mask & (tau[:, hyper_deriv - 1] != 0.0) 141 | t[mask] -= ( 142 | scipy.sqrt(2.0) * n_combined[mask, hyper_deriv - 1] * 143 | tau[mask, hyper_deriv - 1] / 144 | (self.params[hyper_deriv]) ** 2.0 * 145 | scipy.special.eval_hermite( 146 | n_combined[mask, hyper_deriv - 1] - 1, 147 | tau[mask, hyper_deriv - 1] / ( 148 | scipy.sqrt(2.0) * self.params[hyper_deriv] 149 | ) 150 | ) / 151 | scipy.special.eval_hermite( 152 | n_combined[mask, hyper_deriv - 1], 153 | tau[mask, hyper_deriv - 1] / ( 154 | scipy.sqrt(2.0) * self.params[hyper_deriv] 155 | ) 156 | ) 157 | ) 158 | hermite_factors[:, hyper_deriv - 1] *= t 159 | 160 | k = j_chain_factors * scipy.prod(hermite_factors, axis=1) * k 161 | # Take care of hyperparameter derivatives: 162 | if hyper_deriv is None: 163 | return k 164 | elif hyper_deriv == 0: 165 | return 2.0 * k / self.params[0] if self.params[0] != 0.0 \ 166 | else scipy.zeros_like(k) 167 | else: 168 | # Keep efficient form for only_first_order: 169 | if only_first_order: 170 | return (tau[:, hyper_deriv - 1]) ** 2.0 / \ 171 | (self.params[hyper_deriv]) ** 3.0 * k 172 | else: 173 | # Was already computed above: 174 | return k 175 | -------------------------------------------------------------------------------- /gptools/kernel/src/matern.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Stanford University and the Authors 3 | This program is distributed under the terms of the GNU General Purpose License (GPL). 4 | Refer to http://www.gnu.org/licenses/gpl.txt 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #include "stdio.h" 21 | #include "stdlib.h" 22 | #include "math.h" 23 | #include "matern.h" 24 | 25 | static const double SQRT_5 = 2.2360679774997898; 26 | static const double FIVE_THIRDS = 1.6666666666666667; 27 | 28 | /** 29 | * Return the index of the first appearance of the needle in the haystack, 30 | * or -1 if not found 31 | */ 32 | static int32_t index(const int32_t *haystack, int32_t n, int32_t needle) 33 | { 34 | int32_t i; 35 | for (i = 0; i < n; i++) 36 | if (haystack[i] == needle) 37 | return i; 38 | return -1; 39 | } 40 | 41 | /** 42 | * Calculate the sum of an array of integers of length n 43 | * 44 | */ 45 | static int32_t sum(const int32_t* x, int32_t n) { 46 | int32_t i; 47 | int32_t s = 0; 48 | for (i = 0; i < n; i++) { 49 | s+= x[i]; 50 | } 51 | return s; 52 | } 53 | 54 | 55 | /** 56 | * Calculate the standardized squared euclidean distance between two 57 | * points in R^d 58 | * 59 | * \sum_{i=1}^d (X[i] - Y[i])^2 / var[i] 60 | */ 61 | static double seuclidean2(const double* X, const double* Y, const double* var, int32_t d) 62 | { 63 | int32_t i; 64 | double disp; 65 | double r2 = 0.0; 66 | for (i = 0; i < d; i++) { 67 | disp = X[i] - Y[i]; 68 | r2 = r2 + disp*disp / var[i]; 69 | } 70 | return r2; 71 | } 72 | 73 | 74 | /** 75 | * Evaluate the direct Matern5/2 kernel between two points X, Y 76 | */ 77 | static double kernel(const double *X, const double *Y, 78 | int32_t d, const double* var) 79 | { 80 | 81 | double r2, s5r; 82 | r2 = seuclidean2(X, Y, var, d); 83 | if (r2 == 0) 84 | return 1; 85 | 86 | s5r = SQRT_5 * sqrt(r2); 87 | return (1.0 + s5r + FIVE_THIRDS * r2) * exp(-s5r); 88 | } 89 | 90 | 91 | /** 92 | * Evaluate the derivative of the Matern 5/2 kernel with respect 93 | * to the nth coordinate of X 94 | */ 95 | static double dkernel_dXn(const double *X, const double *Y, 96 | int32_t n, int32_t d, const double* var) 97 | { 98 | double r2, s5r, dr_dXn_times_r, dkernel_dr_over_r; 99 | r2 = seuclidean2(X, Y, var, d); 100 | if (r2 == 0) 101 | return 0; 102 | s5r = SQRT_5 * sqrt(r2); 103 | dr_dXn_times_r = (X[n] - Y[n]) / var[n]; 104 | dkernel_dr_over_r = - FIVE_THIRDS * (1 + s5r) * exp(-s5r); 105 | return dkernel_dr_over_r * dr_dXn_times_r; 106 | } 107 | 108 | /** 109 | * Evaluate the 2nd derivative of the Matern 5/2 kernel with respect 110 | * to the nth coordinate of X and the mth coordinate of Y 111 | */ 112 | static double d2kernel_dXndYm(const double *X, const double *Y, 113 | int32_t n, int32_t m, int32_t d, 114 | const double* var) 115 | { 116 | 117 | double r2, r, dr_dXn, dr_dYm, d2r_dXndYm_times_r3, s5r; 118 | double exp_minus_s5r, dkernel_dr_over_r, d2kernel_dr2; 119 | double term1, term2; 120 | 121 | r2 = seuclidean2(X, Y, var, d); 122 | 123 | if (r2 == 0) { 124 | if (n == m) 125 | return FIVE_THIRDS / (var[n]); 126 | return 0; 127 | } 128 | 129 | r = sqrt(r2); 130 | dr_dXn = (X[n] - Y[n]) / (r * var[n]); 131 | dr_dYm = -(X[m] - Y[m]) / (r * var[m]); 132 | 133 | d2r_dXndYm_times_r3 = (X[n] - Y[n]) * (X[m] - Y[m]) / (var[n]*var[m]); 134 | 135 | if (n == m) 136 | d2r_dXndYm_times_r3 -= r*r / (var[n]); 137 | 138 | s5r = SQRT_5 * r; 139 | exp_minus_s5r = exp(-s5r); 140 | dkernel_dr_over_r = - FIVE_THIRDS * (1 + s5r) * exp_minus_s5r; 141 | d2kernel_dr2 = FIVE_THIRDS * (5*r2 - s5r - 1) * exp_minus_s5r; 142 | 143 | term1 = dkernel_dr_over_r * d2r_dXndYm_times_r3 / r2; 144 | term2 = d2kernel_dr2 * dr_dXn * dr_dYm; 145 | 146 | return term1 + term2; 147 | } 148 | 149 | 150 | /** 151 | * Evaluate the Matern 5/2 kernel between a pair of points xi, xj in R^d. 152 | * 153 | * Parameters 154 | * ---------- 155 | * xi : array, (d,) 156 | * xj : array, (d,) 157 | * ni : array, (d,) 158 | * The derivative orders with respect to xi 159 | * nj : array, (d,) 160 | * The derivative orders with respect to xj 161 | * d : int 162 | * var : array, (d,) 163 | * The squared length scale (variance) in each direction 164 | */ 165 | double matern52(const double *xi, const double *xj, 166 | const int32_t* ni, const int32_t* nj, 167 | int32_t d, const double* var) 168 | { 169 | int32_t indexi = index(ni, d, 1); 170 | int32_t indexj = index(nj, d, 1); 171 | int32_t si = sum(ni, d); 172 | int32_t sj = sum(nj, d); 173 | if (si > 1 || sj > 1) { 174 | fprintf(stderr, "Derivative orders above 1 are not supported"); 175 | exit(1); 176 | } 177 | 178 | if (indexi == -1 && indexj == -1) 179 | return kernel(xi, xj, d, var); 180 | if (indexi > -1 && indexj == -1) 181 | return dkernel_dXn(xi, xj, indexi, d, var); 182 | if (indexi == -1 && indexj > -1) { 183 | return dkernel_dXn(xj, xi, indexj, d, var); 184 | } 185 | return d2kernel_dXndYm(xi, xj, indexi, indexj, d, var); 186 | } 187 | -------------------------------------------------------------------------------- /gptools/splines.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | 3 | import scipy 4 | 5 | def spev(t_int, C, deg, x, cov_C=None, M_spline=False, I_spline=False, n=0): 6 | """Evaluate a B-, M- or I-spline with the specified internal knots, order and coefficients. 7 | 8 | `deg` boundary knots are appended at both sides of the domain. 9 | 10 | The zeroth order basis functions are modified to ensure continuity at the 11 | right-hand boundary. 12 | 13 | Note that the I-splines include the :math:`i=0` case in order to have a "DC 14 | offset". This way your functions do not have to start at zero. If you want 15 | to not include this, simply set the first coefficient in `C` to zero. 16 | 17 | Parameters 18 | ---------- 19 | t_int : array of float, (`M`,) 20 | The internal knot locations. Must be monotonic (this is NOT checked). 21 | C : array of float, (`M + deg - 1`,) 22 | The coefficients applied to the basis functions. 23 | deg : nonnegative int 24 | The polynomial degree to use. 25 | x : array of float, (`N`,) 26 | The locations to evaluate the spline at. 27 | cov_C : array of float, (`M + deg - 1`,) or (`M + deg - 1`, `M + deg - 1`), optional 28 | The covariance matrix of the coefficients. If a 1d array is passed, this 29 | is treated as the variance. If None, then the uncertainty is not 30 | computed. 31 | M_spline : bool, optional 32 | If True, compute the M-spline instead of the B-spline. M-splines are 33 | normalized to integrate to unity, as opposed to B-splines which sum to 34 | unity at all points. Default is False (compute B-spline). 35 | I_spline : bool, optional 36 | If True, compute the I-spline instead of the B-spline. Note that this 37 | will override `M_spline`. I-splines are the integrals of the M-splines, 38 | and hence ensure curves are monotonic if all coefficients are of the 39 | same sign. Note that the I-splines returned will be of polynomial degree 40 | `deg` (i.e., the integral of what is returned from calling the function 41 | with `deg=deg-1` and `M_spline=True`. Default is False (compute B-spline 42 | or M-spline). 43 | n : int, optional 44 | The derivative order to compute. Default is 0. If `n>d`, all zeros are 45 | returned (i.e., the discontinuities are not included). 46 | 47 | Returns 48 | ------- 49 | `y` or (`y`, `cov_y`): The values (and possibly uncertainties) of the spline 50 | at the specified locations. 51 | """ 52 | C = scipy.asarray(C, dtype=float) 53 | t_int = scipy.asarray(t_int, dtype=float) 54 | if (t_int != scipy.sort(t_int)).any(): 55 | raise ValueError("Knots must be in increasing order!") 56 | # if len(scipy.unique(t_int)) != len(t_int): 57 | # raise ValueError("Knots must be unique!") 58 | if n > deg: 59 | return scipy.zeros_like(x, dtype=float) 60 | if I_spline: 61 | # I_{i,k} = int_L^x M_{i,k}(u)du, so just take the derivative of the 62 | # underlying M-spline. Discarding the first coefficient dumps the "DC 63 | # offset" term. 64 | if cov_C is not None: 65 | cov_C = scipy.asarray(cov_C) 66 | if cov_C.ndim == 1: 67 | cov_C = cov_C[1:] 68 | elif cov_C.ndim == 2: 69 | cov_C = cov_C[1:, 1:] 70 | if n > 0: 71 | return spev( 72 | t_int, C[1:], deg - 1, x, 73 | cov_C=cov_C, M_spline=True, I_spline=False, n=n - 1 74 | ) 75 | M_spline = True 76 | if n > 0: 77 | if M_spline: 78 | t = scipy.concatenate(([t_int[0]] * deg, t_int, [t_int[-1]] * deg)) 79 | C = (deg + 1.0) * ( 80 | C[1:] / (t[deg + 2:len(t_int) + 2 * deg] - t[1:len(t_int) + deg - 1]) - 81 | C[:-1] / (t[deg + 1:len(t_int) + 2 * deg - 1] - t[:len(t_int) + deg - 2]) 82 | ) 83 | else: 84 | C = C[1:] - C[:-1] 85 | return spev( 86 | t_int, C, deg - 1, x, 87 | cov_C=cov_C, M_spline=True, I_spline=False, n=n - 1 88 | ) 89 | 90 | if len(C) != len(t_int) + deg - 1: 91 | raise ValueError("Length of C must be equal to M + deg - 1!") 92 | 93 | # Append the external knots directly at the boundary: 94 | t = scipy.concatenate(([t_int[0]] * deg, t_int, [t_int[-1]] * deg)) 95 | 96 | # Compute the different orders: 97 | B = scipy.zeros((deg + 1, len(t) - 1, len(x))) 98 | 99 | # NOTE: The first dimension is indexed by deg, and is zero-indexed. 100 | 101 | # Zeroth order: constant function 102 | d = 0 103 | for i in range(deg, deg + len(t_int) - 2 + 1): 104 | # The second condition contains a hack to make the basis functions 105 | # continuous at the right-hand edge. 106 | mask = (t[i] <= x) & ( 107 | (x < t[i + 1]) | ((i == deg + len(t_int) - 2) & (x == t[-1])) 108 | ) 109 | B[d, i, mask] = 1.0 / (t[i + 1] - t[i]) if M_spline else 1.0 110 | 111 | # Loop over other orders: 112 | for d in range(1, deg + 1): 113 | for i in range(deg - d, deg + len(t_int) - 2 + 1): 114 | if t[i + d] != t[i]: 115 | v = (x - t[i]) * B[d - 1, i, :] 116 | if not M_spline: 117 | v /= t[i + d] - t[i] 118 | B[d, i, :] += v 119 | if t[i + d + 1] != t[i + 1]: 120 | v = (t[i + d + 1] - x) * B[d - 1, i + 1, :] 121 | if not M_spline: 122 | v /= t[i + d + 1] - t[i + 1] 123 | B[d, i, :] += v 124 | if M_spline and ((t[i + d] != t[i]) or (t[i + d + 1] != t[i + 1])): 125 | B[d, i, :] *= (d + 1) / (d * (t[i + d + 1] - t[i])) 126 | 127 | B = B[deg, 0:len(C), :].T 128 | 129 | # Now compute the I-splines, if needed: 130 | if I_spline: 131 | I = scipy.zeros_like(B) 132 | for i in range(0, len(C)): 133 | for m in range(i, len(C)): 134 | I[:, i] += (t[m + deg + 1] - t[m]) * B[:, m] / (deg + 1.0) 135 | B = I 136 | 137 | y = B.dot(C) 138 | if cov_C is not None: 139 | cov_C = scipy.asarray(cov_C) 140 | # If there are no covariances, promote cov_C to a diagonal matrix 141 | if cov_C.ndim == 1: 142 | cov_C = scipy.diag(cov_C) 143 | cov_y = B.dot(cov_C).dot(B.T) 144 | return (y, cov_y) 145 | else: 146 | return y 147 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | try: 4 | from setuptools import setup, Extension 5 | except ImportError: 6 | from distutils.core import setup, Extension 7 | 8 | import numpy 9 | from Cython.Distutils import build_ext 10 | 11 | _matern = Extension( 12 | "gptools.kernel._matern", 13 | ["gptools/kernel/_matern.pyx", "gptools/kernel/src/matern.c"], 14 | include_dirs=[numpy.get_include(), 'gptools/kernel/include'] 15 | ) 16 | 17 | setup( 18 | name='gptools', 19 | version='0.2.3', 20 | packages=['gptools', 'gptools.kernel'], 21 | install_requires=['scipy', 'numpy', 'matplotlib', 'mpmath', 'emcee', 'triangle_plot'], 22 | author='Mark Chilenski', 23 | author_email='mark.chilenski@gmail.com', 24 | url='https://github.com/markchil/gptools', 25 | description='Gaussian process regression with derivative constraints and predictions.', 26 | long_description=open('README.rst', 'r').read(), 27 | cmdclass={'build_ext': build_ext}, 28 | ext_modules=[_matern], 29 | license='GPL', 30 | headers=['gptools/kernel/include/matern.h'] 31 | ) -------------------------------------------------------------------------------- /tests/test_matern.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import gptools 3 | 4 | def test_matern_52(): 5 | # This test compares MaternKernelArb and Matern52Kernel using some 6 | # randomly generated points with 0th and 1st derivative observations 7 | 8 | f_X = np.random.RandomState(0).randn(5,2) 9 | f_y = f_X[:,0]**2 + f_X[:,1]**2 10 | g_y_0 = 2*f_X[:, 0] 11 | g_y_1 = 2*f_X[:, 1] 12 | 13 | n_dims = 2 14 | length_scales = np.random.lognormal(size=n_dims).tolist() 15 | K1 = gptools.MaternKernelArb(num_dim=2, 16 | initial_params=[10, 5.0/2.0,] + length_scales) 17 | K2 = gptools.Matern52Kernel(num_dim=2, 18 | initial_params=[10,] + length_scales) 19 | 20 | gp1 = gptools.GaussianProcess(K1) 21 | gp2 = gptools.GaussianProcess(K2) 22 | 23 | 24 | gp1.add_data(f_X, f_y) 25 | gp1.add_data(f_X, g_y_0, n=np.vstack((np.ones(len(f_X)), np.zeros(len(f_X)))).T) 26 | gp1.add_data(f_X, g_y_1, n=np.vstack((np.zeros(len(f_X)), np.ones(len(f_X)))).T) 27 | 28 | k1 = gp1.compute_Kij(gp1.X, None, gp1.n, None) 29 | k2 = gp2.compute_Kij(gp1.X, None, gp1.n, None) 30 | 31 | np.testing.assert_array_almost_equal(k1, k2, decimal=8) 32 | --------------------------------------------------------------------------------