Question

In MATLAB, generate a way to calculate the minimum number of people needed for 2 people...

In MATLAB, generate a way to calculate the minimum number of people needed for 2 people of the sample to have the same birthday.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

clear; clc;
n = 100; % size of 100 random people
I = ones(100, n); % initialize array I to all 1's
k = 1; % initialize since probability for only 1 person is 1
for j = 1 : 100 % begin for loop
I(j) = 1 - k; % each element of I is assigned a probability
k = k * (365 -j)/365; % then calculate new probability and repeat
end % end for loop
plot(I, 'red') % plot the number of people vs. the probability
title('probability of any two people having same birthday in group of people');
xlabel('number of people in the group ');
ylabel('probability of any two people having the same birthday');

Add a comment
Know the answer?
Add Answer to:
In MATLAB, generate a way to calculate the minimum number of people needed for 2 people...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT