******************************************************************** * * ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION * * IF YOU ARE USING INTERNET EXPLORER, CLICK ON VIEW-->SOURCE * AND THEN COPY FROM THAT VIEW. OTHERWISE THE COPY AND PASTE * INTO THE DO EDITOR MAY NOT WORK PROPERLY * ********************************************************************* * program to simulate World Series games, 20 repetitions, p=.5 * Bert Kritzer, June 26, 2002 * Set Seed added October 24, 2002 version 7.0 * clear everything in memory drop _all * set number of repetions (20); each row will be one simulation set obs 20 * set random number seed * students should reset this to a random number chosen from * table B set seed 53 * get winners of each game * use uniform random distribution * probability set to .5 * note: to get another probability of National League winning * change the .5 below to desired probability for new game1-game7: gen X = uniform()>(1-.5) * get outcomes based one first 4, 5, 6, and full seven games * for example, if sum4 equals 4 or 0, it was a 4 game series * if sum5 equals 4 or 1, it was a 5 game series * if sum6 equals 4 or 2, it was a 6 game series * if sum7 equals 4 or 3, it was a 7 game series generate sum4=game1+game2+game3+game4 generate sum5=sum4+game5 if ~inlist(sum4,0,4) generate sum6=sum5+game6 if ~inlist(sum5,1,4) generate sum7=sum6+game7 if ~inlist(sum6,2,4) tab1 sum4-sum7