Skip to content

Commit 974129b

Browse files
AlexAndorraaloctavodia
authored andcommitted
Answers chp 13 (#55)
* Started work on chapter 13 exercises * Finished chapter 13 exercises * Fixed typo in problem 11H6
1 parent 7fcc427 commit 974129b

File tree

3 files changed

+3666
-3
lines changed

3 files changed

+3666
-3
lines changed

Rethinking/Data/oxboys.csv

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
Subject;age;height;Occasion
2+
1;-1;140.5;1
3+
1;-0.7479;143.4;2
4+
1;-0.463;144.8;3
5+
1;-0.1643;147.1;4
6+
1;-0.0027;147.7;5
7+
1;0.2466;150.2;6
8+
1;0.5562;151.7;7
9+
1;0.7781;153.3;8
10+
1;0.9945;155.8;9
11+
2;-1;136.9;1
12+
2;-0.7479;139.1;2
13+
2;-0.463;140.1;3
14+
2;-0.1643;142.6;4
15+
2;-0.0027;143.2;5
16+
2;0.2466;144;6
17+
2;0.5562;145.8;7
18+
2;0.7781;146.8;8
19+
2;0.9945;148.3;9
20+
3;-1;150;1
21+
3;-0.7479;152.1;2
22+
3;-0.463;153.9;3
23+
3;-0.1643;155.8;4
24+
3;-0.0027;156;5
25+
3;0.2466;156.9;6
26+
3;0.5562;157.4;7
27+
3;0.7781;159.1;8
28+
3;0.9945;160.6;9
29+
4;-1;155.7;1
30+
4;-0.7479;158.7;2
31+
4;-0.463;160.6;3
32+
4;-0.1643;163.3;4
33+
4;-0.0027;164.4;5
34+
4;0.2466;167.3;6
35+
4;0.5562;170.7;7
36+
4;0.7781;172;8
37+
4;0.9945;174.8;9
38+
5;-1;145.8;1
39+
5;-0.7479;147.3;2
40+
5;-0.4493;148.7;3
41+
5;-0.1643;149.78;4
42+
5;-0.0027;150.22;5
43+
5;0.2466;152.5;6
44+
5;0.5562;154.8;7
45+
5;0.7781;156.4;8
46+
5;0.9973;158.7;9
47+
6;-1;142.4;1
48+
6;-0.7479;143.8;2
49+
6;-0.463;145.2;3
50+
6;-0.1643;146.3;4
51+
6;-0.0027;147.1;5
52+
6;0.2466;148.1;6
53+
6;0.5562;148.9;7
54+
6;0.7781;149.1;8
55+
6;0.9945;151;9
56+
7;-1;141.3;1
57+
7;-0.7479;142.4;2
58+
7;-0.4493;144.3;3
59+
7;-0.1643;145.2;4
60+
7;0;146.1;5
61+
7;0.2466;146.8;6
62+
7;0.5562;147.9;7
63+
7;0.7945;150.5;8
64+
7;0.9945;151.8;9
65+
8;-1;141.7;1
66+
8;-0.7479;143.7;2
67+
8;-0.463;145.1;3
68+
8;-0.1643;147.9;4
69+
8;-0.0027;148.1;5
70+
8;0.2466;149.6;6
71+
8;0.5562;150.99;7
72+
8;0.7945;154.1;8
73+
8;1.0055;154.9;9
74+
9;-1;132.7;1
75+
9;-0.7479;134.1;2
76+
9;-0.4493;135.3;3
77+
9;-0.1643;136.6;4
78+
9;-0.0027;137.5;5
79+
9;0.2466;139.1;6
80+
9;0.5562;140.9;7
81+
9;0.7945;143.7;8
82+
9;0.9945;144.7;9
83+
10;-1;126.2;1
84+
10;-0.7479;128.2;2
85+
10;-0.463;129;3
86+
10;-0.1643;129.4;4
87+
10;-0.0027;129.59;5
88+
10;0.2466;130.6;6
89+
10;0.5562;132.5;7
90+
10;0.7781;133.4;8
91+
10;0.9945;134.2;9
92+
11;-1;142.5;1
93+
11;-0.7479;143.8;2
94+
11;-0.463;145.6;3
95+
11;-0.1643;148.3;4
96+
11;-0.0027;149.4;5
97+
11;0.2466;151.6;6
98+
11;0.5562;154.8;7
99+
11;0.7781;156.9;8
100+
11;0.9945;159.2;9
101+
12;-1;149.9;1
102+
12;-0.7479;151.7;2
103+
12;-0.463;153.3;3
104+
12;-0.1643;156.1;4
105+
12;0;156.7;5
106+
12;0.2466;157.8;6
107+
12;0.5562;160.7;7
108+
12;0.7781;162.7;8
109+
12;0.9945;163.8;9
110+
13;-1;148.9;1
111+
13;-0.715;149.8;2
112+
13;-0.463;151.7;3
113+
13;-0.1643;154.4;4
114+
13;-0.0027;155.5;5
115+
13;0.2466;156.4;6
116+
13;0.5562;161.4;7
117+
13;0.7781;163.9;8
118+
13;0.9945;164.6;9
119+
14;-1;151.6;1
120+
14;-0.7479;153.2;2
121+
14;-0.463;155.2;3
122+
14;-0.1643;157.3;4
123+
14;0;159.1;5
124+
14;0.2466;160.9;6
125+
14;0.5562;164.4;7
126+
14;0.7781;166.9;8
127+
14;0.9945;168.4;9
128+
15;-1;137.5;1
129+
15;-0.7479;139.3;2
130+
15;-0.463;140.9;3
131+
15;-0.1643;142.7;4
132+
15;-0.0027;144.2;5
133+
15;0.2466;145.7;6
134+
15;0.5562;147.09;7
135+
15;0.7781;150.2;8
136+
15;0.9945;152.3;9
137+
16;-1;142.8;1
138+
16;-0.7479;144.9;2
139+
16;-0.463;145;3
140+
16;-0.1643;146.7;4
141+
16;-0.0027;147.2;5
142+
16;0.2466;148.9;6
143+
16;0.5562;150.1;7
144+
16;0.7781;151;8
145+
16;0.9945;152.2;9
146+
17;-1;134.9;1
147+
17;-0.7479;137.4;2
148+
17;-0.463;138.2;3
149+
17;-0.1643;140.2;4
150+
17;-0.0027;143.6;5
151+
17;0.2466;144.2;6
152+
17;0.5562;147.9;7
153+
17;0.7781;150.3;8
154+
17;0.9945;151.8;9
155+
18;-1;145.5;1
156+
18;-0.7479;146.2;2
157+
18;-0.463;148.2;3
158+
18;-0.1643;150.3;4
159+
18;-0.0027;152;5
160+
18;0.2466;152.3;6
161+
18;0.5562;154.3;7
162+
18;0.7781;156.2;8
163+
18;0.9945;156.8;9
164+
19;-1;156.9;1
165+
19;-0.7479;157.9;2
166+
19;-0.463;160.3;3
167+
19;-0.1643;161.9;4
168+
19;0;163.8;5
169+
19;0.2466;165.5;6
170+
19;0.5562;169.9;7
171+
19;0.7781;172.4;8
172+
19;0.9945;174.4;9
173+
20;-1;146.5;1
174+
20;-0.7479;148.4;2
175+
20;-0.463;149.3;3
176+
20;-0.1643;151.2;4
177+
20;-0.0027;152.1;5
178+
20;0.2466;152.4;6
179+
20;0.5562;153.9;7
180+
20;0.7781;154.9;8
181+
20;0.9945;155.4;9
182+
21;-1;143.9;1
183+
21;-0.7479;145.1;2
184+
21;-0.463;147;3
185+
21;-0.1643;149.2;4
186+
21;-0.0027;149.8;5
187+
21;0.2466;151.5;6
188+
21;0.5562;153.17;7
189+
21;0.7781;156.9;8
190+
21;0.9945;159.6;9
191+
22;-1;147.4;1
192+
22;-0.7479;148.8;2
193+
22;-0.463;150.1;3
194+
22;-0.1643;152.5;4
195+
22;-0.0027;154.7;5
196+
22;0.2466;156;6
197+
22;0.5562;158.4;7
198+
22;0.7781;161.5;8
199+
22;0.9945;163.3;9
200+
23;-1;144.5;1
201+
23;-0.7479;146;2
202+
23;-0.463;147.4;3
203+
23;-0.1643;149.2;4
204+
23;-0.0027;150.8;5
205+
23;0.2466;152.5;6
206+
23;0.5562;155;7
207+
23;0.7781;156.8;8
208+
23;0.9945;158.8;9
209+
24;-1;147.8;1
210+
24;-0.7479;148.2;2
211+
24;-0.463;150.2;3
212+
24;-0.1643;151;4
213+
24;-0.0027;152.2;5
214+
24;0.2466;153.6;6
215+
24;0.5562;155.8;7
216+
24;0.7781;159.2;8
217+
24;0.9945;161.6;9
218+
25;-1;135.5;1
219+
25;-0.7479;136.6;2
220+
25;-0.463;137.3;3
221+
25;-0.1643;138.2;4
222+
25;-0.0027;139;5
223+
25;0.2466;139.5;6
224+
25;0.5562;141;7
225+
25;0.7808;142.7;8
226+
25;0.9945;143.9;9
227+
26;-1;132.2;1
228+
26;-0.7479;134.3;2
229+
26;-0.463;135.1;3
230+
26;-0.1643;136.7;4
231+
26;-0.0027;138.4;5
232+
26;0.2466;138.9;6
233+
26;0.5562;141.8;7
234+
26;0.7781;142.6;8
235+
26;1.0055;143.1;9

Rethinking/end-of-chapter-practice-problems/ch-11.ipynb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3319,9 +3319,6 @@
33193319
"p_ppc = sp.special.expit(post_fish[\"ap\"] + post_fish[\"bp0\"]*1 + post_fish[\"bc0\"]*0)\n",
33203320
"lam_ppc = np.exp(np.log(1) + post_fish[\"al\"] + post_fish[\"bp\"]*1 + post_fish[\"bc\"]*0)\n",
33213321
"\n",
3322-
"#print(f\"V1 Mean number of fish caught: {((1-p_ppc) * lam_ppc).mean()}\")\n",
3323-
"#print(f\"V1 89% HPD of number of fish caught: {az.hpd((1-p_ppc) * lam_ppc, credible_interval=0.89)}\")\n",
3324-
"\n",
33253322
"# Push posterior values through the ZIP likelihood\n",
33263323
"zeros = np.random.binomial(n=1, p=p_ppc, size=(Nobs, Nsamples)) \n",
33273324
"obs_fish = (1 - zeros) * np.random.poisson(lam_ppc, size=(Nobs, Nsamples))\n",

0 commit comments

Comments
 (0)