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

Write a MATLAB program to simulate the following experiments. (a) Draw a dice 10

ID: 3371473 • Letter: W

Question

Write a MATLAB program to simulate the following experiments.

(a) Draw a dice 100 times. That is, generate a sequence of 100 random numbers from the set {1, . . . , 6}. Call this sequence X1, . . . , X100. Plot the histogram of X1, . . . , X100, with bin centers {1, . . . , 6}. Do not use a for-loop in your code. Submit your program and plot.

(b) Repeat (a) by drawing the dice 10000 times. (c) Draw another dice 100 times. Call this sequence Y1, . . . , Y100. Let Zi = Xi +Yi for i = 1, . . . , 100. Plot the histogram of Z1, . . . , Z100. Submit your plot.

(d) Repeat (d) by drawing the dices 10000 times.

(e) Using the histogram found in (d), find the probability that 4 < Zi ? 7. (f) In (c)-(d), Zi is a sum of two random variables Xi and Yi . What if we sum more random variables? That is, Zi = X (1) i + X (2) i + . . . + X (K) i . Let K = 10. Plot the histogram of {Z1, . . . , Z10000}. Submit your histogram. Pay attention to the bin centers.

(g) Repeat

(f) by setting K = 100. Plot the histogram of {Z1, . . . , Z10000}. Submit your histogram. Pay attention to the bin centers.

****Really just need help with parts e-f****

Explanation / Answer

Before writing the program, like to explain the functions required for the program.

According to the program we need to generate a sequence of numbers so Loops are used in the program.

Loops: Loops are MATLAB constructs that permit us to execute a sequence of statements more than once.

For loop:

for k = expr   // k is a loop variable and expr is the loop control expression,

body

end

Example:

for k = 1:5

x = k

end

So we use a loop format for writing a sequence of numbers, X:Y. This is just shorthand for make a list of numbers from 1 to 6 increasing by 1 each step

n = 1e3;

Number_Dice = 1;

Roll1 = NULL // This initiates the variable

Roll2 = NULL

For (i in 1:100)

{

roll1[i] = Roll1dice(1)

roll2[i] = Roll1dice(1)

}

Sum(roll1 == roll2)

print(i)

RF11 = cumsum(S==11)/(1:100);

plot(1:100,RF11) // Plot the values

hold on

RF12 = cumsum(S==12)./(1:100);

plot(1:n,RF12,'r')

xlabel('Number of Rolls')

ylabel('Relative Frequency')

legend('Sum = 11', 'Sum = 12') grid on

figure S_Support = (1*Number_Dice):(6*Number_Dice);

hist(S,S_Support) // to draw the histogram

N_S_Sim = hist((roll1+roll2),density = 100 , breaks = 1:12,prob =T); // Breaks says that bins to start at 1, end at 12.

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