You are on page 1of 2

URK20RA1033 EXERCISE 3

August 3, 2021

[4]: #Fitting of binomial distribution and finding theoretical frequencies


x <- c(0,1,2,3,4,5,6)
f <- c(5,18,28,12,7,6,4)
mean <- sum(f*x)/sum(f)
n<-length(x)-1
p <- mean/n
mean
p
binom<-dbinom(x=0:6,n,p)
N <- sum(f)
sum(f)
freq <- N*binom
freq
.
2.4
0.4
80
1. 3.73248 2. 14.92992 3. 24.8832 4. 22.1184 5. 11.0592 6. 2.94912 7. 0.32768
[6]: #Fitting of binomial distribution and finding theoretical frequencies
x <- c(0,1,2,3,4)
f <- c(5,29,36,25,5)
mean <- sum(f*x)/sum(f)
n<-length(x)-1
p <- mean/n
mean
p
binom<-dbinom(x=0:4,n,p)
N <- sum(f)
sum(f)
freq <- N*binom
freq
.
1.96
0.49
100

1
1. 6.765201 2. 25.999596 3. 37.470006 4. 24.000396 5. 5.764801
[9]: #Fitting of poisson distribution and finding theoretical frequencies
x <- c(0,1,2,3,4)
f <- c(19,18,8,4,1)
lambda <- sum(f*x)/sum(f)
lambda
poisson<-dpois(x=0:4,lambda)
N <-sum(f)
freq <- N*poisson
freq
.
1
1. 18.3939720585721 2. 18.3939720585721 3. 9.19698602928606 4. 3.06566200976202
5. 0.766415502440505
[10]: #Fitting of poisson distribution and finding theoretical frequencies
x <- c(0,1,2,3,4)
f <- c(211,90,19,5,0)
lambda <- sum(f*x)/sum(f)
lambda
poisson<-dpois(x=0:4,lambda)
N <-sum(f)
freq <- N*poisson
freq
.
0.44
1. 209.311836852021 2. 92.0972082148892 3. 20.2613858072756 4. 2.97166991840042
5. 0.326883691024046
[ ]:
.

You might also like