Skip to content

Commit be87469

Browse files
authored
Add files via upload
1 parent ee04cd2 commit be87469

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

Session-1/our_prior.pptx

1.5 MB
Binary file not shown.

Session-1/session 1.pdf

45.6 KB
Binary file not shown.

Session-1/session1.r

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#####################################################################
2+
################ SESSION 1 ####################################
3+
#####################################################################
4+
5+
6+
###### beta distribution ########
7+
8+
9+
10+
par(mfrow=c(3,3))
11+
12+
for (a in c(0.5,1, 10)) {
13+
for (b in c(0.5, 1,10)) {
14+
15+
plot(function(x)dbeta(x, a, b), xlim=c(0,1), ylab="", xlab = "")
16+
title(paste("Beta","(","a=",a,",","b=",b,")"))
17+
}
18+
}
19+
20+
21+
22+
23+
######################## smoking rate from Barcelona ###########################
24+
25+
par(mfrow=c(1,1))
26+
27+
a <- 4
28+
b <- 6
29+
30+
31+
plot(function(x)dbeta(x, a, b), xlim=c(0,1), ylab="", xlab = "", lwd=2, col="yellow")
32+
title(paste("Beta","(","a=",a,",","b=",b,")"))
33+
34+
35+
36+
37+
################# probability to get head when you throw a coin ################
38+
39+
par(mfrow=c(1,1))
40+
41+
a <- 100
42+
b <- 100
43+
44+
45+
plot(function(x)dbeta(x, a, b), xlim=c(0,1), ylab="", xlab = "")
46+
title(paste("Prior distribution: Beta","(","a=",a,",","b=",b,")"))
47+
48+
49+
50+
####### DATA
51+
52+
N <- 25
53+
y <- 11
54+
55+
56+
#### likelihood function
57+
58+
k <- integrate(function(th)dbinom(y,N,th), lower=0, upper=1)$value
59+
60+
plot(function(th)dbinom(y,N,th)/k, xlim=c(0,1), xlab=expression(theta), main="likelihood function", add=T, lty=2)
61+
legend("topright", c("prior","likelihood"), lty=c(1,2))
62+
abline(v=y/N, lty=3)
63+
64+
65+
66+
67+
####################### height of adult catalan people ####################
68+
69+
70+
prior1 <- c(m=190, s=1)
71+
72+
73+
74+
##### prior distribution
75+
76+
plot(function(x)dnorm(x,prior1[1], prior1[2]),xlim=c(120,220), ylab="", xlab = expression(mu),main=paste("Normal(",prior1[1],",",prior1[2],")",sep=""))
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+

0 commit comments

Comments
 (0)