|
4913 | 4913 | "metadata": {},
|
4914 | 4914 | "source": [
|
4915 | 4915 | "You can also use {meth}`xarray.Dataset.stack` if you only want to combine the chain and draw dimensions. {func}`arviz.extract` is a convenience function aimed at taking care of the most common subsetting operations with MCMC samples. It can:\n",
|
4916 |
| - "- Combine chains and draws\n", |
4917 |
| - "- Return a subset of variables (with optional filtering with regular expressions or string matching)\n", |
4918 |
| - "- Return a subset of samples. Moreover by default it returns a random subset to prevent getting non-representative samples due to bad mixing.\n", |
4919 |
| - "- Access any group" |
| 4916 | + "- Combine chains and draws.\n", |
| 4917 | + "- Return a subset of variables (with optional filtering with regular expressions or string matching).\n", |
| 4918 | + "- Return a subset of samples. Moreover, by default it returns a random subset to prevent getting non-representative samples due to bad mixing.\n", |
| 4919 | + "- Access any group." |
4920 | 4920 | ]
|
4921 | 4921 | },
|
4922 | 4922 | {
|
|
5573 | 5573 | "metadata": {},
|
5574 | 5574 | "source": [
|
5575 | 5575 | ":::{tip}\n",
|
5576 |
| - "Use a random seed to get the same subset from multiple groups: `az.extract(idata, num_samples=100, rng=3)` and `az.extract(idata, group=\"log_likelihood\", num_samples=100, rng=3)` will continue to have matching samples\n", |
| 5576 | + "Use a random seed to get the same subset from multiple groups: `az.extract(idata, num_samples=100, rng=3)` and `az.extract(idata, group=\"log_likelihood\", num_samples=100, rng=3)` will continue to have matching samples.\n", |
5577 | 5577 | ":::"
|
5578 | 5578 | ]
|
5579 | 5579 | },
|
|
5642 | 5642 | "source": [
|
5643 | 5643 | "## Get coordinate values\n",
|
5644 | 5644 | "\n",
|
5645 |
| - "What are the names of the groups in our hierarchical model? You can access them from the coordinate name `school` in this case" |
| 5645 | + "What are the names of the groups in our hierarchical model? You can access them from the coordinate name `school` in this case:" |
5646 | 5646 | ]
|
5647 | 5647 | },
|
5648 | 5648 | {
|
|
17648 | 17648 | "\n",
|
17649 | 17649 | "You can use xarray for these pushforward operations and store them as a new variable in the posterior group. You'll then be able to plot them with ArviZ functions, calculate stats and diagnostics on them (like the {func}`~arviz.mcse`) or save and share the inferencedata object with the pushforward quantities included. \n",
|
17650 | 17650 | "\n",
|
17651 |
| - "Compute the rolling mean of $\\log(\\tau)$ with {meth}`xarray.DataArray.rolling`, storing the result in the posterior" |
| 17651 | + "Compute the rolling mean of $\\log(\\tau)$ with {meth}`xarray.DataArray.rolling`, storing the result in the posterior:" |
17652 | 17652 | ]
|
17653 | 17653 | },
|
17654 | 17654 | {
|
|
17701 | 17701 | "```\n",
|
17702 | 17702 | ":::\n",
|
17703 | 17703 | "\n",
|
17704 |
| - "The `theta_shool_diff` variable in the posterior has kept the named dimensions and coordinates:" |
| 17704 | + "The `theta_school_diff` variable in the posterior has kept the named dimensions and coordinates:" |
17705 | 17705 | ]
|
17706 | 17706 | },
|
17707 | 17707 | {
|
|
18641 | 18641 | "cell_type": "markdown",
|
18642 | 18642 | "metadata": {},
|
18643 | 18643 | "source": [
|
18644 |
| - "For more advanced subsetting (the equivalent to what is sometimes called \"fancy indexing\" in NumPy) you need to provide the indices as {class}`~xarray.DataArray` objects:" |
| 18644 | + "For more advanced subsetting (the equivalent to what is sometimes called \"fancy indexing\" in NumPy), you need to provide the indices as {class}`~xarray.DataArray` objects:" |
18645 | 18645 | ]
|
18646 | 18646 | },
|
18647 | 18647 | {
|
|
19093 | 19093 | "cell_type": "markdown",
|
19094 | 19094 | "metadata": {},
|
19095 | 19095 | "source": [
|
19096 |
| - "Using lists or NumPy arrays instead of DataArrays does colum/row based indexing. As you can see, the result has 9 values of `theta_shool_diff` instead of the 3 pairs of difference we selected in the previous cell:" |
| 19096 | + "Using lists or NumPy arrays instead of DataArrays does colum/row based indexing. As you can see, the result has 9 values of `theta_school_diff` instead of the 3 pairs of difference we selected in the previous cell:" |
19097 | 19097 | ]
|
19098 | 19098 | },
|
19099 | 19099 | {
|
|
19550 | 19550 | },
|
19551 | 19551 | {
|
19552 | 19552 | "cell_type": "markdown",
|
19553 |
| - "metadata": {}, |
| 19553 | + "metadata": { |
| 19554 | + "jupyter": { |
| 19555 | + "source_hidden": true |
| 19556 | + } |
| 19557 | + }, |
19554 | 19558 | "source": [
|
19555 | 19559 | "## Add new chains using concat"
|
19556 | 19560 | ]
|
|
27957 | 27961 | "cell_type": "markdown",
|
27958 | 27962 | "metadata": {},
|
27959 | 27963 | "source": [
|
27960 |
| - "You can also pass a lambda function in `map`" |
| 27964 | + "You can also pass a lambda function in `map`." |
27961 | 27965 | ]
|
27962 | 27966 | },
|
27963 | 27967 | {
|
|
32040 | 32044 | "cell_type": "markdown",
|
32041 | 32045 | "metadata": {},
|
32042 | 32046 | "source": [
|
32043 |
| - "You can also add extra coordinates using `map`" |
| 32047 | + "You can also add extra coordinates using `map`." |
32044 | 32048 | ]
|
32045 | 32049 | },
|
32046 | 32050 | {
|
|
36122 | 36126 | ],
|
36123 | 36127 | "metadata": {
|
36124 | 36128 | "kernelspec": {
|
36125 |
| - "display_name": "Python 3 (ipykernel)", |
| 36129 | + "display_name": "Python [conda env:base] *", |
36126 | 36130 | "language": "python",
|
36127 |
| - "name": "python3" |
| 36131 | + "name": "conda-base-py" |
36128 | 36132 | },
|
36129 | 36133 | "language_info": {
|
36130 | 36134 | "codemirror_mode": {
|
|
36136 | 36140 | "name": "python",
|
36137 | 36141 | "nbconvert_exporter": "python",
|
36138 | 36142 | "pygments_lexer": "ipython3",
|
36139 |
| - "version": "3.11.8" |
| 36143 | + "version": "3.11.5" |
36140 | 36144 | },
|
36141 | 36145 | "varInspector": {
|
36142 | 36146 | "cols": {
|
|
0 commit comments