Question: Case 4 Setup: make 1 set of nrolls outcome: rollSet (1 x nrolls) Code to call function: % Case 4: 3 sets of rolls of

Case 4

Setup: make 1 set of nrolls

outcome: rollSet (1 x nrolls)

Case 4 Setup: make 1 set of nrolls outcome: rollSet (1 x

Code to call function:

% Case 4: 3 sets of rolls of 2 dice, one set with fair dice (F),

% one set with moderate bias (M), one set with strong bias (S).

% All sets have same number of rolls.

% Can you figure out which is set F, set M, and set B?

% SETUP:

% nrolls, number of rolls for each rollSet

% rollPairs, pair totals of rollSets (3 x nrolls)

% RESULTS:

% bincounts, bin counts of each rollSet (3 x 11)

% setMeans, mean of each rollSet (3 x 1)

% setVariances, variance of each rollSet (3 x 1)

% -------------------------------------------------------------------------

clear

clc

fprintf('RUN Dice_4_bias.m ');

% SETUP SECTION -----------------------------------------------------------

% generate roll sets

nrolls= 3600;

% generate rollSet1 here

%bkpts1= [11,21,31,41,51,61]; % fair die

bkpts1= [21,29,37,45,53,61]; % biased to '1' by 10

[rollSet1]= biasrollSet(bkpts1,nrolls);

% generate rollSet2 here

%bkpts2= [11,21,31,41,51,61]; % fair die

bkpts2= [21,29,37,45,53,61]; % biased to '1'

[rollSet2]= biasrollSet(bkpts2,nrolls);

rollPairs= rollSet1 +rollSet2;

% SIMULATION SECTION ------------------------------------------------------

[meanrollPairs,variance,bincounts,binfracs]= Dice_4_fcn(nrolls,rollPairs);

% DISPLAY SECTION ---------------------------------------------------------

% setup section

fprintf(' Dice 4 setup: ');

fprintf(' nrolls=%6.0f ',nrolls);

fmt11= [' rollSet1(1:12)= [',repmat('%3.0f',1,12),'] '];

fprintf(fmt11,rollSet1(1,1:12));

fmt12= [' rollSet2(1:12)= [',repmat('%3.0f',1,12),'] '];

fprintf(fmt12,rollSet2(1,1:12));

fmt13= [' rollPairs(1:12)= [',repmat('%3.0f',1,12),'] '];

fprintf(fmt13,rollPairs(1,1:12));

% results section

fprintf(' Dice 4 results: ');

fmt2= [' bincounts= [',repmat('%4.0f',1,11),' ] '];

fprintf(fmt2,bincounts(1,1:11));

fprintf(' meanrollPairs= %8.2f ',meanrollPairs);

fmt3= (' variance *10e-6= %8.0f ');

fprintf(fmt3,variance*10e6);

figure (1)

x= 2:1:12;

subplot(2,1,1)

bar(x,binfracs);

title('Bin fractions: actual and expected');

xlabel('actual bin fractions');

subplot(2,1,2)

expbinfracs= [1,2,3,4,5,6,5,4,3,2,1]/36;

bar(x,expbinfracs);

xlabel('expected bin fractions');

fprintf(' ');

% -------------------------------------------------------------------------

% biasrollSet function ----------------------------------------------------

function [rollSet]= biasrollSet(bkpts,nrolls)

rollSet= zeros(1,nrolls);

for n= 1:1:nrolls

rnum= randi(60);

i= 1;

while i

if rnum

rollSet(1,n)= i;

i= 7;

else

i= i+1;

end

end

end

end

% -------------------------------------------------------------------------

Enter your function from Test Case 4 into the space below. Click the run button to test your code output using the provided script Click the submit button to have your work assessed. % % Case 4: 3 sets of rolls of 2 dice, one set with fair dice (F), one set with moderate bias (M), one set with strong bias (S). All sets have same number of rolls. Can you figure out which is set F, set M, and set B? SETUP: % nrolls, number of rolls for each rollset % rollPairs, pair totals of rollsets (3 x nrolls) % RESULTS: % bincounts, bin counts of each rollset (3 X 11) % setMeans, mean of each rollset (3 x 1) setVariances, variance of each rollset (3 X 1) Enter your function from Test Case 4 into the space below. Click the run button to test your code output using the provided script Click the submit button to have your work assessed. % % Case 4: 3 sets of rolls of 2 dice, one set with fair dice (F), one set with moderate bias (M), one set with strong bias (S). All sets have same number of rolls. Can you figure out which is set F, set M, and set B? SETUP: % nrolls, number of rolls for each rollset % rollPairs, pair totals of rollsets (3 x nrolls) % RESULTS: % bincounts, bin counts of each rollset (3 X 11) % setMeans, mean of each rollset (3 x 1) setVariances, variance of each rollset (3 X 1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!