Professional Documents
Culture Documents
Template For Lab Assignment 4: Bailey Sinclair November 4th, 2019
Template For Lab Assignment 4: Bailey Sinclair November 4th, 2019
Template For Lab Assignment 4: Bailey Sinclair November 4th, 2019
Bailey Sinclair
Contents
1 Problem 1: 1
1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Problem 2: 2
2.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3 Problem 3: 2
1 Problem 1:
1.1
dbinom(c(7,8,9),100,0.01)
sum(dbinom(10:29,100,0.01))
## [1] 7.631588e-08
pbinom(29,100,0.01)-pbinom(9,100,0.01)
## [1] 7.631588e-08
1.4
x=dbinom(0:10,100,0.01)
y=dpois(0:10,1)
matplot(cbind(x,y),type='o',pch=20)
1
0.3
cbind(x, y)
0.2
0.1
0.0
2 4 6 8 10
2 Problem 2:
2.1
2.2
mean(firstrn)
## [1] 50.02341
var(firstrn)
## [1] 16.09301
3 Problem 3:
N = 1000
n = 2000
2
mu = .5
sigma = sqrt(.25)
y = rep(NA, N)
for(i in 1:N){
x = rbinom(n, 1, 0.5)
x = seq(-4,4,0.01)
Bernoulli (0.5)
0.0 0.1 0.2 0.3 0.4 0.5 0.6
Density
−3 −2 −1 0 1 2 3
N = 1000
n = 2000
mu = .5
sigma = sqrt(1/12)
y = rep(NA, N)
for(i in 1:N){
x = seq(-4,4,0.01)
3
points(x, dnorm(x), type = "l", col = "red")
Uniform (0,1)
0.6
0.5
0.4
Density
0.3
0.2
0.1
0.0
−3 −2 −1 0 1 2 3
N = 1000
n = 2000
mu = 1
sigma = 1
y = rep(NA, N)
for(i in 1:N){
x = rexp(n)
x = seq(-4,4,0.01)
4
Density
−3
−2
−1
5
y
0
Poisson (1)
1
2
3