macro sixdice rolls thesums; magic ofsix. #This macro simulates the magic dice problem. Six dice are rolled #and their sum is the response. The six dice can be standard dice or #some of them can be magic dice. A magic die has (3 4 5 5 6 6) on its #faces. fyi: The mean sum of six standard dice is 21.0 and the std dev #is 4.18. The mean of four magic and two standard dice is 26.3. These #values are provided to support sample size calculations in the DOE text. #Variable definitions: #rolls (a constant) is the number of trials #thesums (a column) is the output sum of the six dice #ofsix (a constant) is the number of magic dice in the set of six #Example calling statement: # mtb> %sixdice 40 c1; # subc> magic 4. #Paul G. Mathews #Mathews, Malnar, and Bailey #217 Third Street, Fairport Harbor, OH 44077 #pmathews@apk.net #440-350-0911 #Copyright (c) 15 March 2001 by PGMathews All rights reserved mcolumn thesums stddice notstd keepers temp mconstant rolls ofsix i j start default ofsix=0 note note This macro runs very slowly. Please be patient. note Macro running ... note set stddice #define a standard die (1 2 3 4 5 6) end set notstd #define a magic die (3 4 5 5 6 6) end erase keepers erase thesums if (ofsix>0 and ofsix<7) #there are some magic dice do i=1:rolls do j=1:ofsix #roll the magic ones sample 1 notstd temp let keepers(j)=temp(1) enddo let start=ofsix+1 #roll the standard ones do j=start:6 sample 1 stddice temp let keepers(j)=temp(1) enddo let thesums(i)=sum(keepers) #here's where the sums go enddo elseif ofsix=0 #all of the dice are standard do i=1:rolls do j=1:6 sample 1 stddice temp let keepers(j)=temp(1) enddo let thesums(i)=sum(keepers) enddo else note The number of magic dice must be between 0 and 6 endif endmacro