Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following coin flipping problem: For a single flip of an unfair coi

ID: 673336 • Letter: C

Question

Consider the following coin flipping problem: For a single flip of an unfair coin, the likelihood of a head is 60% and a tail is 40% The unfair coin is flipped 5 times and number of "heads" outcomes is noted. It is desired to find the probability of "3 heads out of 5 flips", i.e. P(3 heads out of 5 flips) = ? Show that the theoretical probability of "3 heads out of 5 flips" where P(head) = 0.60 is P(3 heads out of 5 flips) = 0.3456 Simulate the problem: simulate the 5 flips and determine if 3 heads resulted run part i) above 1,000 times and find how many times "3 heads out of 5 flips"

Explanation / Answer

Program:


clc
head=0;
tail=0;   
pHead=60;%probability of head
pTail=40;%probability of tail
flips=5; %no.of trials
for i=1:flips
toss=randi([0,1]); % 0 for head 1 for tails
if toss==0 %if head happens
head=head+1; %a should increase by 1
elseif toss==1 %else if tails happens
tail=tail+1; %b should increase by 1
end %end of if
end
if head==3
disp('Success! 3 heads in 5 flips');
else
disp('Failure! 3 heads not in 5 flips');
end
b = nchoosek(flips,3)/i;
fprintf('Probability of getting 3 heads in 5 flips %f',b);
flips=1000; %no.of trials
count=0;
for i=1:flips
toss=randi([0,1]); % 0 for head 1 for tails
if toss==0 %if head happens
head=head+1; %a should increase by 1
elseif toss==1 %else if tails happens
tail=tail+1; %b should increase by 1
if(head==3)
count=count+1;
head=0;
end %end of if
end
end
fprintf(' %d times 3 heads occurred in %d flips',count,flips);

Output:

Failure! 3 heads not in 5 flips
Probability of getting 3 heads in 5 flips 2.000000
0 times 3 heads occurred in 1000 flips>>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote