Avin
Avin

Reputation: 11

Calculating Probability of Earthquakes in a Four-Week Period Using Poisson Distribution in Octave

Question: In an area of a country, it is known that earthquakes occur 1.4 times in 8 days in an average sense since the dawn of history. However, there were 15 earthquakes in the last four weeks. Calculate the probability of 15 and more earthquakes occurring in four consecutive weeks. Write code in octave. Avoid using built in functions. Here is my attempt at the code

clc

lambda = 1.4/8 % Average number of earthquakes in one day
mu = lambda * 28 % Expected number of earthquakes in four weeks
p=0

% Calculate the probability of 15 and more earthquakes occurring in four consecutive weeks
for i = 0:14
 p = (exp(-mu)*(mu^i))/ factorial(i)
end

b= (1-p)*100

disp(['The probability of 15 and more earthquakes occurring in four consecutive weeks is: ' num2str(b)]);

I have tried to use Poisson distribution method to solve this but I am getting the wrong output. My output is 0.018312, which I think is too small. I have tried changing the formula but I think I am calculating the lambda wrong. Also I have not used the inbuilt command since it is not allowed. Can someone please help me with this?

Upvotes: 1

Views: 58

Answers (0)

Related Questions