Skip to content

Commit d5abdf7

Browse files
committed
Merge pull request CamDavidsonPilon#1 from CamDavidsonPilon/master
Pulling changes
2 parents c149c15 + 988755f commit d5abdf7

File tree

31 files changed

+3854
-861
lines changed

31 files changed

+3854
-861
lines changed

Chapter1_Introduction/Chapter1_Introduction.ipynb

Lines changed: 88 additions & 86 deletions
Large diffs are not rendered by default.

Chapter2_MorePyMC/MorePyMC.ipynb

Lines changed: 451 additions & 213 deletions
Large diffs are not rendered by default.

Chapter2_MorePyMC/daft_plot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#daft drawing for SMS example
2+
import matplotlib.pyplot as plt
3+
4+
25

36
try:
47
import daft
@@ -12,7 +15,7 @@
1215
pgm.add_node(daft.Node("lambda1", r"$\lambda_1$", 5.5, 3.2,))
1316
pgm.add_node(daft.Node("lambda2", r"$\lambda_2$", 6.5, 3.2))
1417
pgm.add_node(daft.Node("lambda", r"$\lambda$", 5.0, 2.0))
15-
pgm.add_node(daft.Node("obs", "SMS\nobs", 5.0, 1.0, 1.2, observed=True))
18+
pgm.add_node(daft.Node("obs", "obs", 5.0, 1.0, 1.2, observed=True))
1619

1720

1821

@@ -24,5 +27,5 @@
2427

2528
pgm.add_edge("lambda", "obs")
2629
pgm.render()
27-
30+
plt.figure( figsize=(12,5) )
2831
plt.show()

Chapter2_MorePyMC/separation_plot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ def separation_plot( p, y, **kwargs ):
3636
ax = fig.add_subplot(M, 1, i+1)
3737
ix = np.argsort( p[:,i] )
3838
#plot the different bars
39-
bars = ax.bar( np.arange(n)-1, np.ones(n), width=1.,
39+
bars = ax.bar( np.arange(n), np.ones(n), width=1.,
4040
color = colors_bmh[ y[ix].astype(int) ],
4141
edgecolor = 'none')
42-
ax.plot( np.arange(n), p[ix,i], "k", linewidth = 0.75)
42+
ax.plot( np.arange(n), p[ix,i], "k",
43+
linewidth = 1.,drawstyle="steps-post" )
4344
#create expected value bar.
4445
ax.vlines( [(1-p[ix,i]).sum()], [0], [1] )
4546
#ax.grid(False)

Chapter2_MorePyMC/sms_model.png

41.2 KB
Loading

Chapter3_MCMC/IntroMCMC.ipynb

Lines changed: 95 additions & 48 deletions
Large diffs are not rendered by default.

Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb

Lines changed: 270 additions & 196 deletions
Large diffs are not rendered by default.
49.2 KB
Loading

Chapter4_TheGreatestTheoremNeverTold/top_pic_comments.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1+
import sys
2+
13
import numpy as np
24
from IPython.core.display import Image
35

4-
56
import praw
67

78

89
reddit = praw.Reddit("BayesianMethodsForHackers")
910
subreddit = reddit.get_subreddit( "pics" )
1011

1112
top_submissions = subreddit.get_top()
12-
top_submission = top_submissions.next()
13-
while "i.imgur.com" not in top_submission.url:
14-
#make sure it is linking to an image, not a webpage.
13+
14+
15+
n_pic = int( sys.argv[1] ) if sys.argv[1] else 1
16+
17+
i = 0
18+
while i < n_pic:
1519
top_submission = top_submissions.next()
20+
while "i.imgur.com" not in top_submission.url:
21+
#make sure it is linking to an image, not a webpage.
22+
top_submission = top_submissions.next()
23+
i+=1
1624

1725
print "Title of submission: \n", top_submission.title
1826
top_post_url = top_submission.url
@@ -34,6 +42,9 @@
3442

3543
votes = np.array( [ upvotes, downvotes] ).T
3644

45+
46+
47+
3748

3849

3950

Chapter5_LossFunctions/LossFunctions.ipynb

Lines changed: 69 additions & 60 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)