Question

In: Computer Science

Fill in the blanks in the following simulation for R, which finds the approximate variance of...

Fill in the blanks in the following simulation for R, which finds the approximate variance of N, the number of rolls of a die needed to get the face having just one dot.

onesixth <- 1/6

sumn <- 0

sumn2 <- 0

for (i in 1:10000) {

n <- 0

while(TRUE) { ________________________________________

if (______________________________ < onesixth) break

}

sumn <- sumn + n

sumn2 <- sumn2 + n^2

}

approxvarn <- ____________________________________________

cat("the approx. value of Var(N) is ",approxvarn,"\n")

Solutions

Expert Solution

Solution:

onesixth <- 1/6

sumn <- 0

sumn2 <- 0

for (i in 1:10000) {

n <- 0

while(TRUE) { n <- n + 1

if (runif(1) < onesixth) break

}

sumn <- sumn + n

sumn2 <- sumn2 + n^2

}

approxvarn <- sumn2/10000 - (sumn/10000)^2

cat("the approx. value of Var(N) is ",approxvarn,"\n")

Sample Output:

the approx. value of Var(N) is  29.28388 

Related Solutions

Fill in the blanks: Consider the following equilibrium and fill in the blanks with either increase...
Fill in the blanks: Consider the following equilibrium and fill in the blanks with either increase or decrease. I2(s) + 5F2(g) ⇌ 2IF5(g) A decrease in volume results in a Blank 1 in pressure which will Blank 2 the amount of IF5.
Fill in the blanks on the following table
 Fill in the blanks on the following tableE&pshareholder basisdistributiondividendreturn of capitalcapital gain20,000300,00080,000120,00010,000170,000220,000100,000170,00020,000080,000<20,000>50,000170,000
Fill in the blanks in each of the following statements
Fill in the blanks in each of the following statementsa) --------- allows you to build JavaFx GUIS using drag and drop techniques.b) The elements in the scene graph are called --------------c) A(n) ----------- file contains the description of a JavaFX GUI.d) The method ---------------- is called by FMXLLoader before the GUI is displayed
Fill in the blanks with an appropriate suggestion for the following.
Fill in the blanks with an appropriate suggestion for the following.(i) If there is no trade-off involved when we get a good, then it is called a _______________ good.(ii) If expected future price falls for a good, it's current demand _____________________ .(iii) Pencil and erasers are a pair of ___________________goods for consumers
Fill in the blanks to complete the following table.
Fill in the blanks to complete the following table.SymbolIon FormedNumber of Electrons in IonNumber of Protons in IonF__________9Te_____54_____II−_______________Mg2+_____12Part AComplete the first column of the table.Express your answer as a chemical symbol.Part BComplete the second column of the table.Express your answer as ions. Enter your answers in order given in the table, from top to bottom, separated by a comma.Part CComplete the third column of the table.Express your answer as integers. Enter your answers in order given in the table, from...
C++ Fill in the blanks please You are required to fill in the blanks in this...
C++ Fill in the blanks please You are required to fill in the blanks in this program. Consider that: -In main, the variables price and quantity were given the names of p (double) and q (int), respectively. -In the getData function, the parameters associated with the main variables p and q were called pp and pq, respectively. // Prototype: Do not include the names // of the variables in the prototype void getData (FILLTHEBLANK , FILLTHEBLANK); int main () {...
Given the following program with fill in the blanks, implement the PQ class which is priority...
Given the following program with fill in the blanks, implement the PQ class which is priority Queue MAX heap; the higher the number, the higher the prority of that number. None of the public methods has been implemented. You will need to write other methods to help implement some of the methods. For example you will need to implement bubbleUp to help with the insert method. Methods to implement: insert -> insert one element into the PQ and maintain heap...
Fill in the blanks in the following table. At which level of output do we obtain...
Fill in the blanks in the following table. At which level of output do we obtain maximum profit? What is the relationship between marginal revenue and marginal cost at the profit-maximizing level of output? Level of Output Total Revenue Total Cost Profit Marginal Revenue Marginal Cost Marginal Profit 20 2400 1900 420 100 21 2800 120 22 3180 140 23 3540 160 24 3880 180 25 4200 200 26 4500 220 27 4780            240 28 5040 260 29 5280 280...
Fill in the blanks with the following numbers, not the words, for this and all the...
Fill in the blanks with the following numbers, not the words, for this and all the questions that follow. Jot them down so you won't have to keep scrolling up to the top to see what they are: Demand = 1 Supply = 2 Right = 3 Left = 4 Up = 5 Down = 6 QUESTION 6 Suppose the dollar were to strengthen in international currency markets. That is, the price of the dollar, in terms of other national...
Fill in the blanks with the following numbers, not the words, for this and all the...
Fill in the blanks with the following numbers, not the words, for this and all the questions that follow. Jot them down so you won't have to keep scrolling up to the top to see what they are: Demand = 1 Supply = 2 Right = 3 Left = 4 Up = 5 Down = 6 QUESTION 4 Consider the case where an important technological innovation (e.g., the personal computer, iPhone, Internet, etc.) made labor more productive. This would cause...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT