|
4138 | 4138 | "cell_type": "markdown", |
4139 | 4139 | "metadata": {}, |
4140 | 4140 | "source": [ |
4141 | | - "## From PyMC3" |
| 4141 | + "## From PyMC" |
4142 | 4142 | ] |
4143 | 4143 | }, |
4144 | 4144 | { |
4145 | 4145 | "cell_type": "code", |
4146 | | - "execution_count": 2, |
| 4146 | + "execution_count": null, |
4147 | 4147 | "metadata": { |
4148 | 4148 | "ExecuteTime": { |
4149 | 4149 | "end_time": "2020-06-19T06:23:42.715900Z", |
|
4152 | 4152 | }, |
4153 | 4153 | "outputs": [], |
4154 | 4154 | "source": [ |
4155 | | - "import pymc3 as pm\n", |
| 4155 | + "import pymc as pm\n", |
4156 | 4156 | "\n", |
4157 | 4157 | "draws = 500\n", |
4158 | 4158 | "chains = 2\n", |
|
4166 | 4166 | }, |
4167 | 4167 | { |
4168 | 4168 | "cell_type": "code", |
4169 | | - "execution_count": 7, |
| 4169 | + "execution_count": null, |
4170 | 4170 | "metadata": { |
4171 | 4171 | "ExecuteTime": { |
4172 | 4172 | "end_time": "2020-06-05T06:47:16.996019Z", |
@@ -10202,24 +10202,19 @@ |
10202 | 10202 | ], |
10203 | 10203 | "source": [ |
10204 | 10204 | "with pm.Model() as model:\n", |
10205 | | - " mu = pm.Normal(\"mu\", mu=0, sd=5)\n", |
| 10205 | + " mu = pm.Normal(\"mu\", mu=0, sigma=5)\n", |
10206 | 10206 | " tau = pm.HalfCauchy(\"tau\", beta=5)\n", |
10207 | | - " theta_tilde = pm.Normal(\"theta_tilde\", mu=0, sd=1, shape=eight_school_data[\"J\"])\n", |
| 10207 | + " theta_tilde = pm.Normal(\"theta_tilde\", mu=0, sigma=1, shape=eight_school_data[\"J\"])\n", |
| 10208 | + " \n", |
10208 | 10209 | " theta = pm.Deterministic(\"theta\", mu + tau * theta_tilde)\n", |
10209 | | - " pm.Normal(\"obs\", mu=theta, sd=eight_school_data[\"sigma\"], observed=eight_school_data[\"y\"])\n", |
| 10210 | + " \n", |
| 10211 | + " pm.Normal(\"obs\", mu=theta, sigma=eight_school_data[\"sigma\"], observed=eight_school_data[\"y\"])\n", |
10210 | 10212 | "\n", |
10211 | | - " trace = pm.sample(draws, chains=chains)\n", |
10212 | | - " prior = pm.sample_prior_predictive()\n", |
10213 | | - " posterior_predictive = pm.sample_posterior_predictive(trace)\n", |
| 10213 | + " idata = pm.sample(draws=draws, chains=chains)\n", |
| 10214 | + " idata.extend(pm.sample_prior_predictive())\n", |
| 10215 | + " idata.extend(pm.sample_posterior_predictive(idata))\n", |
10214 | 10216 | "\n", |
10215 | | - " pm_data = az.from_pymc3(\n", |
10216 | | - " trace=trace,\n", |
10217 | | - " prior=prior,\n", |
10218 | | - " posterior_predictive=posterior_predictive,\n", |
10219 | | - " coords={\"school\": np.arange(eight_school_data[\"J\"])},\n", |
10220 | | - " dims={\"theta\": [\"school\"], \"theta_tilde\": [\"school\"]},\n", |
10221 | | - " )\n", |
10222 | | - "pm_data" |
| 10217 | + "idata" |
10223 | 10218 | ] |
10224 | 10219 | }, |
10225 | 10220 | { |
|
0 commit comments