data = work.one;
p1 = 1/12; \*\* probability of rolling -1 \*\*;
p2 = 3/12; \*\* probability of rolling 0 \*\*;
p3 = 2/12; \*\* probability of rolling 1 \*\*;
p4 = 2/12; \*\* probability of rolling 2 \*\*;
p5 = 3/12; \*\* probability of rolling 3 \*\*;
p6 = 1/12; \*\* probability of rolling 4 \*\*;
seed = 12;
array d (9) d1-d9;
do game = 1 to 10;
do a = 1 to 2;
flag = 9;
do while (flag gt 0);
do i = 1 to flag;
d(i) = rantbl(seed, p1, p2, p3, p4, p5, p6);
output;
end;
flag = flag - 1;
end;
end;
end;
run;
接下来,我需要
我尝试为这三个值创建一个新数组,但是我不确定如何告诉它仅将最低值相加。
我什至不确定我是否会以正确的方式进行第一个循环。任何见解将不胜感激!
作业说明实际上仅指示应该进行模拟,而不是要从中进行报告。
可能需要或可能不需要四层细节:
tier tier details
--------------------------- -------------------------
each roll of a die round half hole die score
each score for a hole round half hole holescore
each score for a half-round round half halfscore
each score for a round round roundscore
这些层中的每个层都是其较低层的集合,所有层都不能存储在单个“垂直”表中。每层的枢纽将创建许多跨变量,以便在单行中记录一次回合的模拟。
汇总表示例:
仅用于频率和分数的数组以及计算的概率表。孔滚动迭代期间孔轨迹的最小分数。在计算数组的统计信息时使用of array-name(*)
语法。
* presume the 12-sided dice have uniform face roll probability;
data
eachroll(keep=round half hole die score)
eachhole(keep=round half hole holescore)
eachhalf(keep=round half halfscore)
eachround(keep=round roundscore)
;
array freqs (6) _temporary_ ( 1,3,2,2,3,1);
array scores(6) _temporary_ (-1,0,1,2,3,4);
array probs (6) _temporary_ ;
do _n_ = 1 to dim(freqs);
probs(_n_) = freqs(_n_) / sum(of freqs(*));
end;
put (_all_) (=/);
call streaminit(12345);
do round = 1 to 1000;
roundscore = 0;
do half = 'front', 'back';
halfscore = 0;
do hole = 1 to 9;
minscore = max (of scores(*)) + 1;
do die = 1 to 10-hole;
score = scores(rand('table', of probs(*)));
output eachroll;
minscore = min(minscore, score);
end;
holescore = minscore;
output eachhole;
end;
halfscore + holescore;
output eachhalf;
end;
roundscore + halfscore;
output eachround;
end;
run;
整个回合为单行分数:
data
rounds(keep=round roundscore halfscores: holescores:)
;
array freqs (6) _temporary_ ( 1,3,2,2,3,1);
array scores(6) _temporary_ (-1,0,1,2,3,4);
array probs (6) _temporary_ ;
do _n_ = 1 to dim(freqs);
probs(_n_) = freqs(_n_) / sum(of freqs(*));
end;
put (_all_) (=/);
call streaminit(12345);
do round = 1 to 1000;
length roundscore 8;
array halfscores(2); * two halves;
array holescores(2, 9); * two halves, nine holes per half;
call missing (of holescores(*));
call missing (of halfscores(*));
do half = 1, 2;
do hole = 1 to 9;
minscore = max (of scores(*)) + 1;
do die = 1 to 10-hole;
score = scores(rand('table', of probs(*)));
minscore = min(minscore, score);
end;
holescores(half,hole) = minscore;
halfscores(half) + minscore;
end;
end;
roundscore = sum (of halfscores(*));
output;
end;
run;