Recall in lecture, the poisson distribution and binomial distribution converges
ID: 3847668 • Letter: R
Question
Recall in lecture, the poisson distribution and binomial distribution converges when the number of trials is large and the probability of success is small. Write the MATLAB function poissonPMF.m (without using MATLAB’s built-in statistics functions). Your function should take n, lambda, and a vector x (representing a vector of integers [0, 1, 2, ... , n] where each value in this vector is evaluated) as input parameters and return a vector representing the pmf values for each value in x. Using your binomialPMF.m solution from Homework 2, comment on the following observations for both binomial and poisson distributions using the following parameters:
- n=10,p=0.5
- n=20,p=0.25
- n=30,p=0.1
- n=50,p=0.01
- n=100,p=0.001
Explanation / Answer
function res=calc_poisson(x,n,lambda)
res= (lambda^x)/((2.71828^lambda)*factorial(x))
end
function res_vec = calc_vec(vec)
sum=0.0
lambda=0.0
for i=1:length(vec)
sum=sum+vec(i)
end
lambda=sum/length(vec)
for i=1:length(vec)
res_vec(i)=calc_poisson(vec(i),size(vec),lambda)
end
end
calc_vec([1,2,3])
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.