Debian Codegraph @

docs/pages/quickstart.ipynb

raw
1 {
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "metadata": {},
6 "source": [
7 "# Getting started\n",
8 "\n",
9 "The only user-facing function in the module is `corner.corner` and, in its simplest form, you use it like this:"
10 ]
11 },
12 {
13 "cell_type": "code",
14 "execution_count": null,
15 "metadata": {},
16 "outputs": [],
17 "source": [
18 "import corner\n",
19 "import numpy as np\n",
20 "\n",
21 "ndim, nsamples = 2, 10000\n",
22 "np.random.seed(42)\n",
23 "samples = np.random.randn(ndim * nsamples).reshape([nsamples, ndim])\n",
24 "figure = corner.corner(samples)"
25 ]
26 },
27 {
28 "cell_type": "markdown",
29 "metadata": {},
30 "source": [
31 "The following snippet demonstrates a few more bells and whistles:"
32 ]
33 },
34 {
35 "cell_type": "code",
36 "execution_count": null,
37 "metadata": {},
38 "outputs": [],
39 "source": [
40 "# Set up the parameters of the problem.\n",
41 "ndim, nsamples = 3, 50000\n",
42 "\n",
43 "# Generate some fake data.\n",
44 "np.random.seed(42)\n",
45 "data1 = np.random.randn(ndim * 4 * nsamples // 5).reshape(\n",
46 " [4 * nsamples // 5, ndim]\n",
47 ")\n",
48 "data2 = 4 * np.random.rand(ndim)[None, :] + np.random.randn(\n",
49 " ndim * nsamples // 5\n",
50 ").reshape([nsamples // 5, ndim])\n",
51 "data = np.vstack([data1, data2])\n",
52 "\n",
53 "# Plot it.\n",
54 "figure = corner.corner(\n",
55 " data,\n",
56 " labels=[\n",
57 " r\"$x$\",\n",
58 " r\"$y$\",\n",
59 " r\"$\\log \\alpha$\",\n",
60 " r\"$\\Gamma \\, [\\mathrm{parsec}]$\",\n",
61 " ],\n",
62 " quantiles=[0.16, 0.5, 0.84],\n",
63 " show_titles=True,\n",
64 " title_kwargs={\"fontsize\": 12},\n",
65 ")"
66 ]
67 },
68 {
69 "cell_type": "markdown",
70 "metadata": {},
71 "source": [
72 "The [API documentation](../api.rst) gives more details about all the arguments available for customization."
73 ]
74 }
75 ],
76 "metadata": {
77 "kernelspec": {
78 "display_name": "Python 3",
79 "language": "python",
80 "name": "python3"
81 },
82 "language_info": {
83 "codemirror_mode": {
84 "name": "ipython",
85 "version": 3
86 },
87 "file_extension": ".py",
88 "mimetype": "text/x-python",
89 "name": "python",
90 "nbconvert_exporter": "python",
91 "pygments_lexer": "python",
92 "version": "3.9.1"
93 }
94 },
95 "nbformat": 4,
96 "nbformat_minor": 4
97 }