Mathsassignment
Mathsassignment
ASSIGNMENT – 2
Submitted To:
Mr. Sathvik S Nayak
Assistant Professor,
Department of Mathematics.
Submitted From:
Jataniya Mihir P.
4MT21CS058
𝑒 −3 ∗ 30 𝑒 −3 ∗ 31 𝑒 −3 ∗ 32
+ + ≈ 0.423
0! 1! 2!
Therefore, the probability of having at most 2 employee layoffs in a week is
approximately 0.4232.
(II) Find the probability of having at most 4 employee layoffs in a week.
P(X ≤ 5) = P(X = 0) + P(X = 1) + P(X = 2) + P(X = 3) + P(X = 4) =
𝑒 −3 ∗ 30 𝑒 −3 ∗ 31 𝑒 −3 ∗ 32 𝑒 −3 ∗ 33 𝑒 −3 ∗ 34 𝑒 −3 ∗ 35
= + + + + +
0! 1! 2! 3! 4! 5!
≈ 0.9161
Therefore, the probability of having at most 5 employee layoffs in a week is
approximately 0.9161
D) MATLAB CODE & GRAPHS:
lambda = 3; % Average rate of employee layoffs per week
x = 0:10; % Range of values for x
% Calculate PMF and CDF
pmf = (exp(-lambda) * lambda.^x) ./ factorial(x);
cdf = cumsum(pmf);
% Calculate specific probabilities
prob_at_most_2 = cdf(2+1); % P(X <= 2)
prob_at_most_5 = cdf(5+1); % P(X <= 5)
prob_at_most_8 = cdf(8+1); % P(X <= 8)
% Plot PMF with grid
figure;
stem(x, pmf, 'b', 'LineWidth', 2);
xlabel('Number of Employee Layoffs (x)');
ylabel('P(X = x)');
title('Poisson Distribution PMF for Employee Layoffs');
grid on;
% Plot CDF with grid
figure;
stairs(x, cdf, 'r', 'LineWidth', 2);
xlabel('Number of Employee Layoffs (x)');
ylabel('P(X ≤ x)');
title('Poisson Distribution CDF for Employee Layoffs');
grid on;
fprintf('The probability that at most 2 layoffs occur is: %.4f\n', prob_at_most_2);
fprintf('The probability that at most 5 layoffs occur is: %.4f\n', prob_at_most_5);
fprintf('The probability that at most 8 layoffs occur is: %.4f\n', prob_at_most_8);
OUTPUT:
The probability that a randomly selected user will spend between 15 and 25
seconds is approximately 0.0214
D) MATLAB CODE & GRAPHS:
mu = 45; sigma = 10;
x = linspace(mu - 4*sigma, mu + 4*sigma, 1000);
pdf = normpdf(x, mu, sigma);
cdf = normcdf(x, mu, sigma);
% Specify the lower and upper bounds for the probability calculation
lower_bound = 15; % Set your desired lower bound
upper_bound = 25; % Set your desired upper bound
% Calculate the probability for the specified range
prob_between = normcdf(upper_bound, mu, sigma) - normcdf(lower_bound, mu,
sigma);
% Print the calculated probability using fprintf
fprintf('Probability that user spends between %d and %d seconds: %.4f\n',
lower_bound, upper_bound, prob_between);
% Plot PDF in Figure 1
figure;
plot(x, pdf);
title('PDF - User Interaction Time');
xlabel('Time (seconds)');
ylabel('Probability Density');
grid on;
% Plot CDF in Figure 2
figure;
plot(x, cdf);
title('CDF - User Interaction Time');
xlabel('Time (seconds)');
ylabel('Cumulative Probability');
grid on;
OUTPUT :