DESCRIPTION Students: Please keep in mind the OMSI rules. Save your files often, make sure OMSI fills your entire screen at all times, etc. Remember that clicking CopyQtoA will copy the entire question box to the answer box. In questions involving code which will PARTIALLY be given to you in the question specs, you may need add new lines. There may not be information given as to where the lines should be inserted. If a question includes test code, make sure to include it in your submission. Do not answer any question with simulation code unless this is specified. MAKE SURE TO RUN THE CODE IN PROBLEMS INVOLVING CODE! Hit the OMSI Submit and Run button. QUESTION (Text answer, 25 pts.) Name the built-in R function which will call a user-specfied function on every row or column of a matrix. QUESTION -ext .R -run 'Rscript omsi_answer2.R' (R code answer, 25 pts.) Consider the board game, Sec. 2.10, but with a bonus being incurred if one lands on either square 1 or square 2 (not 3). And if one lands on square 1 and then rolls a 1 on the bonus, thus reaching square 2, one gets a second bonus roll. Find the probability that after one roll, a player has yet to make a complete circuit of the board, i.e. has not yet reached or passed 0. QUESTION -ext .R -run 'Rscript omsi_answer3.R' (R code answer, 25 pts.) Consider the "Someone tells you" example just below (2.54). Find this probability approximately by simulation instead of analytically, by modifying the code in Sec. 2.14.8. nreps <- 10000 nstops <- 2 # note 2, not 10 countCondition <- 0 countOnly1 <- 0 for (i in 1:nreps) { passengers <- 0 for (j in 1:nstops) { oldpass <- passengers # number arrived at this stop if (passengers > 0) for (k in 1:passengers) if (runif(1) < 0.2) passengers <- passengers - 1 newpass <- sample(0:2,1,prob=c(0.5,0.4,0.1)) passengers <- passengers + newpass # number leave this stop } if ( ) { if ( ) } } print( ) QUESTION -ext .R -run 'Rscript omsi_answer4.R' (R code answer, 25 pts.) This concerns the Preferential Attachment Model, which we will partly simulate in this problem. The function below will generate the node i to which v_k attaches. The current adjacency matrix is adjMat. simAttach <- function(adjMat) { k <- nrow(adjMat) + 1 degrees <- apply( ) prbs <- return(sample( )) } # test it testAM <- rbind(c(0,1,0,0),c(1,0,1,0),c(0,1,0,1),c(0,0,1,0)) reps <- replicate(10000,simAttach(testAM)) table(reps) / 10000