Question 3 - end end Total_game_I_win =...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Question 3 Matlab code clc; clear all ; Number_of_game_I_win = 0; for i = 1:1:100 % New Game, reset both players' scores Me = 0; Opponent = 0; x = 1; y = 1; while if x == 1 % I continue to serve if I win the volley x = binornd(1,0.6); if x == 1 % Add 1 to my score if I win the volley Me = Me + 1; if Me == 21 break % Terminate game as I win end else y = 1; while y == 1 % Opponent continues to serve if he win the volley y = binornd(1,0.5); % Assuming that I win the volley if above statement return 0 if y == 1 % Add 1 to opponent's score if he win the volley Opponent = Opponent + 1; if Opponent == 21 break % Terminate game as Opponent win end else x = 1; % I won the volley hence become server end end end end end i Me Opponent pause if Me == 21 Number_of_game_I_win = Number_of_game_I_win + 1;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end end Total_game_I_win = Number_of_game_I_win Probability = Total_game_I_win/100 Result Total_game_I_win = 82 Probability = 0.8200 Question 4 Distribution Summary Distribution: Triangular Expression: TRIA(2, 5.02, 13) Square Error: 0.000726 Chi Square Test Number of intervals = 28 Degrees of freedom = 26 Test Statistic = 25.4 Corresponding p-value = 0.495 Kolmogorov-Smirnov Test Test Statistic = 0.0201 Corresponding p-value > 0.15 Data Summary Number of Data Points = 1000 Min Data Value = 2.14 Max Data Value = 12.5 Sample Mean = 6.72 Sample Std Dev = 2.35 Histogram Summary Histogram Range = 2 to 13 Number of Intervals = 31...
View Full Document

This note was uploaded on 03/01/2010 for the course EEE ddsds taught by Professor Saa during the Spring '10 term at Abraham Baldwin Agricultural College.

Page1 / 3

Question 3 - end end Total_game_I_win =...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online