Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
starting to switch to ipynb tutorials
- Loading branch information
Showing
11 changed files
with
313 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline\n", | ||
"%config InlineBackend.figure_format = \"retina\"\n", | ||
"\n", | ||
"from __future__ import print_function\n", | ||
"\n", | ||
"from matplotlib import rcParams\n", | ||
"rcParams[\"savefig.dpi\"] = 100\n", | ||
"rcParams[\"figure.dpi\"] = 100\n", | ||
"rcParams[\"font.size\"] = 20" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Quickstart \n", | ||
"\n", | ||
"This notebook was made with the following version of emcee:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'3.0.0.dev0'" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import emcee\n", | ||
"emcee.__version__" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The easiest way to get started with using emcee is to use it for a project. To get you started, here’s an annotated, fully-functional example that demonstrates a standard usage pattern.\n", | ||
"\n", | ||
"## How to sample a multi-dimensional Gaussian\n", | ||
"\n", | ||
"We’re going to demonstrate how you might draw samples from the multivariate Gaussian density given by:\n", | ||
"\n", | ||
"$$\n", | ||
"p(\\vec{x}) \\propto \\exp \\left [ - \\frac{1}{2} (\\vec{x} -\n", | ||
" \\vec{\\mu})^\\mathrm{T} \\, \\Sigma ^{-1} \\, (\\vec{x} - \\vec{\\mu})\n", | ||
" \\right ]\n", | ||
"$$\n", | ||
"\n", | ||
"where $\\vec{\\mu}$ is an $N$-dimensional vector position of the mean of the density and $\\Sigma$ is the square N-by-N covariance matrix.\n", | ||
"\n", | ||
"The first thing that we need to do is import the necessary modules:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import emcee" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Then, we’ll code up a Python function that returns the density $p(\\vec{x})$ for specific values of $\\vec{x}$, $\\vec{\\mu}$ and $\\Sigma^{-1}$. In fact, emcee actually requires the logarithm of $p$. We’ll call it `log_prob`:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"def log_prob(x, mu, icov):\n", | ||
" diff = x - mu\n", | ||
" return -0.5*np.dot(diff,np.dot(icov,diff))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
.. module:: george | ||
|
||
**Note:** This tutorial was generated from an IPython notebook that can be | ||
downloaded `here <../../_static/notebooks/quickstart.ipynb>`_. | ||
|
||
.. _quickstart: | ||
|
||
|
||
Quickstart | ||
========== | ||
|
||
This notebook was made with the following version of emcee: | ||
|
||
.. code:: python | ||
import emcee | ||
emcee.__version__ | ||
.. parsed-literal:: | ||
'3.0.0.dev0' | ||
The easiest way to get started with using emcee is to use it for a | ||
project. To get you started, here’s an annotated, fully-functional | ||
example that demonstrates a standard usage pattern. | ||
|
||
How to sample a multi-dimensional Gaussian | ||
------------------------------------------ | ||
|
||
We’re going to demonstrate how you might draw samples from the | ||
multivariate Gaussian density given by: | ||
|
||
.. math:: | ||
p(\vec{x}) \propto \exp \left [ - \frac{1}{2} (\vec{x} - | ||
\vec{\mu})^\mathrm{T} \, \Sigma ^{-1} \, (\vec{x} - \vec{\mu}) | ||
\right ] | ||
where :math:`\vec{\mu}` is an :math:`N`-dimensional vector position of | ||
the mean of the density and :math:`\Sigma` is the square N-by-N | ||
covariance matrix. | ||
|
||
The first thing that we need to do is import the necessary modules: | ||
|
||
.. code:: python | ||
import numpy as np | ||
import emcee | ||
Then, we’ll code up a Python function that returns the density | ||
:math:`p(\vec{x})` for specific values of :math:`\vec{x}`, | ||
:math:`\vec{\mu}` and :math:`\Sigma^{-1}`. In fact, emcee actually | ||
requires the logarithm of :math:`p`. We’ll call it ``log_prob``: | ||
|
||
.. code:: python | ||
def log_prob(x, mu, icov): | ||
diff = x - mu | ||
return -0.5*np.dot(diff,np.dot(icov,diff)) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{%- extends 'display_priority.tpl' -%} | ||
|
||
{% block header %} | ||
.. module:: george | ||
|
||
**Note:** This tutorial was generated from an IPython notebook that can be | ||
downloaded `here <../../_static/notebooks/{{ resources.metadata.name }}.ipynb>`_. | ||
|
||
.. _{{resources.metadata.name}}: | ||
{% endblock %} | ||
|
||
{% block in_prompt %} | ||
{% endblock in_prompt %} | ||
|
||
{% block output_prompt %} | ||
{% endblock output_prompt %} | ||
|
||
{% block input %} | ||
{%- if cell.source.strip() and not cell.source.startswith("%") -%} | ||
.. code:: python | ||
|
||
{{ cell.source | indent}} | ||
{% endif -%} | ||
{% endblock input %} | ||
|
||
{% block error %} | ||
:: | ||
|
||
{{ super() }} | ||
{% endblock error %} | ||
|
||
{% block traceback_line %} | ||
{{ line | indent | strip_ansi }} | ||
{% endblock traceback_line %} | ||
|
||
{% block execute_result %} | ||
{% block data_priority scoped %} | ||
{{ super() }} | ||
{% endblock %} | ||
{% endblock execute_result %} | ||
|
||
{% block stream %} | ||
.. parsed-literal:: | ||
|
||
{{ output.text | indent }} | ||
{% endblock stream %} | ||
|
||
{% block data_svg %} | ||
.. image:: {{ output.metadata.filenames['image/svg+xml'] | urlencode }} | ||
{% endblock data_svg %} | ||
|
||
{% block data_png %} | ||
.. image:: {{ output.metadata.filenames['image/png'] | urlencode }} | ||
{% endblock data_png %} | ||
|
||
{% block data_jpg %} | ||
.. image:: {{ output.metadata.filenames['image/jpeg'] | urlencode }} | ||
{% endblock data_jpg %} | ||
|
||
{% block data_latex %} | ||
.. math:: | ||
|
||
{{ output.data['text/latex'] | strip_dollars | indent }} | ||
{% endblock data_latex %} | ||
|
||
{% block data_text scoped %} | ||
.. parsed-literal:: | ||
|
||
{{ output.data['text/plain'] | indent }} | ||
{% endblock data_text %} | ||
|
||
{% block data_html scoped %} | ||
.. raw:: html | ||
|
||
{{ output.data['text/html'] | indent }} | ||
{% endblock data_html %} | ||
|
||
{% block markdowncell scoped %} | ||
{{ cell.source | markdown2rst }} | ||
{% endblock markdowncell %} | ||
|
||
{%- block rawcell scoped -%} | ||
{%- if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) %} | ||
{{cell.source}} | ||
{% endif -%} | ||
{%- endblock rawcell -%} | ||
|
||
{% block headingcell scoped %} | ||
{{ ("#" * cell.level + cell.source) | replace('\n', ' ') | markdown2rst }} | ||
{% endblock headingcell %} | ||
|
||
{% block unknowncell scoped %} | ||
unknown type {{cell.type}} | ||
{% endblock unknowncell %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters