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

Write a Matlab code that will generate a random number, which can take only two

ID: 3763646 • Letter: W

Question

Write a Matlab code that will generate a random number, which can take only two

possible values H (representing a heads outcome in a random coin toss) and T

(representing a tails in a random coin toss). Generate a sequence of toss outcomes of 10

random trials. Count how many times H and T are generated out of the 10 outcomes.

How can you estimate the probability of H and T in this case?

Repeat the experiment with a 100, 500 and 1000 outcomes generated. Estimate the

probabilities in each case

please i want a answer of codes for matlab that works for each case given above for 10,100.500,1000

with the same variables H and T

Explanation / Answer

heads = 0;
tails = 0;
n = input('Enter the number of trials: ');
for i = 1:n
    x = randn();
    if(x > 0)
    toss = 'H';
    heads = heads+1;
else
    toss = 'T';
    tails = tails+1;
end
end
display (heads);
display(tails);
headsProbability = heads/i;
tailsProbability = tails/i;
display(headsProbability);
display(tailsProbability);

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