(i) Complete the following code of a function that simulates playing the lotto 6/49 with the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(i) Complete the following code of a function that simulates playing the lotto 6/49 with the same ticket until you win the jackpot. You have to insert code where it says HERE. play_lotto <-function(){ n <- 0 ticket <- # HERE: create a vector of your 6 favorite numbers in increasing order! draw <- c(0,0,0,0,0,0) # initializes the vector that will contain the numbers drawn while (!all (ticket=-draw)){ n <- n + 1 draw <- #HERE: draw a random sample of 6 numbers from 1:49 in increasing order } return (n) } (ii) To test the code, first modify it so that it simulates the lotto 4/49 (sample of 4 numbers instead of 6). It should complete faster, and help you debug any problems you may have. (iii) Run the code twice for the lotto 6/49. The value returned by the function gives the number of times you had to play before winning the jackpot. The code will probably take several minutes to terminate, so be patient (do something else while it runs). 2 (iv) Assuming you play once a week, how many years did it take before winning the jackpot? (v) Assuming each ticket cost $3, and that the jackpot is $16,000,000, what is your net earning after playing this many times? (i) Complete the following code of a function that simulates playing the lotto 6/49 with the same ticket until you win the jackpot. You must insert code where it says HERE NOTE: If you copy past this chunk, you need to remove the text 'eval=FALSE, include=FALSE' from your that the code will display and run. version so (ii) To test the code, first modify it so that it simulates the lotto 4/49 (sample of 4 numbers instead of 6). It should complete faster, and help you debug any problems you may have. Present this modified code and its result. (iii) Run the code for the lotto 6/49. The value returned by the function gives the number of times you had to play before winning the jackpot. The code will probably take several minutes to terminate, so be patient (do something else while it runs). (iv) Assuming you play once a week, how many years did it take before winning the jackpot? (v) Assuming each ticket cost $3, and that the jackpot is $16,000,000, what is your net earnings after playing this many times? (i) Complete the following code of a function that simulates playing the lotto 6/49 with the same ticket until you win the jackpot. You have to insert code where it says HERE. play_lotto <-function(){ n <- 0 ticket <- # HERE: create a vector of your 6 favorite numbers in increasing order! draw <- c(0,0,0,0,0,0) # initializes the vector that will contain the numbers drawn while (!all (ticket=-draw)){ n <- n + 1 draw <- #HERE: draw a random sample of 6 numbers from 1:49 in increasing order } return (n) } (ii) To test the code, first modify it so that it simulates the lotto 4/49 (sample of 4 numbers instead of 6). It should complete faster, and help you debug any problems you may have. (iii) Run the code twice for the lotto 6/49. The value returned by the function gives the number of times you had to play before winning the jackpot. The code will probably take several minutes to terminate, so be patient (do something else while it runs). 2 (iv) Assuming you play once a week, how many years did it take before winning the jackpot? (v) Assuming each ticket cost $3, and that the jackpot is $16,000,000, what is your net earning after playing this many times? (i) Complete the following code of a function that simulates playing the lotto 6/49 with the same ticket until you win the jackpot. You must insert code where it says HERE NOTE: If you copy past this chunk, you need to remove the text 'eval=FALSE, include=FALSE' from your that the code will display and run. version so (ii) To test the code, first modify it so that it simulates the lotto 4/49 (sample of 4 numbers instead of 6). It should complete faster, and help you debug any problems you may have. Present this modified code and its result. (iii) Run the code for the lotto 6/49. The value returned by the function gives the number of times you had to play before winning the jackpot. The code will probably take several minutes to terminate, so be patient (do something else while it runs). (iv) Assuming you play once a week, how many years did it take before winning the jackpot? (v) Assuming each ticket cost $3, and that the jackpot is $16,000,000, what is your net earnings after playing this many times?
Expert Answer:
Answer rating: 100% (QA)
Note The Sample run for 649 Lotto run is runing for more than an hour So fo... View the full answer
Related Book For
College Mathematics for Business Economics Life Sciences and Social Sciences
ISBN: 978-0321614001
12th edition
Authors: Raymond A. Barnett, Michael R. Ziegler, Karl E. Byleen
Posted Date:
Students also viewed these accounting questions
-
According to By the Numbers, approximately how many years did it take for real GDP per capita in the United States to double from $5,000 to $10,000? How about from $25,000 to $50,000? During which...
-
Sketch the graph of a function that is continuous everywhere except at x = 3 and is continuous from the left at 3.
-
(a) Sketch the graph of a function that has two local maxima, one local minimum, and no absolute minimum. (b) Sketch the graph of a function that has three local minima, two local maxima, and seven...
-
The standard cost card for Balsam indicates each unit of product should take 1.5 hours of direct labor at a cost of $10 per hour. During the current period, Balsam produced 3,000 units, used 5,000...
-
Why do users of private- company financial statements often prefer non- consolidated financial statements?
-
What is e-tailing? How does it work?
-
Blatt Consulting Services is interested in comparing the number of customer accounts managed by its consultants. The chart below is a default chart produced in Excel. a. Which preattentive attributes...
-
Nine experts rated two brands of Colombian coffee in a taste testing experiment. A rating on a 7 point scale (1 = extremely unpleasing, 7 = extremely pleasing) is given for each of four...
-
A company sells two products: a standard model and a deluxe model. The standard model sells for $50 and has a contribution margin ratio of 40%. The deluxe model sells for $100 and has a contribution...
-
The Fashion Rack has a monthly accounting period. All transactions are recorded in a general journal. Postings are made from the general journal to the accounts receivable ledger, accounts payable...
-
Hotshot Company sells personal computers with a two-year warranty. During 2018, the company sells 350 computers. On the basis of past experience, the warranty costs are estimated to be $300 per...
-
In order of frequency of occurrence of short-circuit faults in three-phase power systems, list those: _________, _________, _________, _________.
-
Breakers of the \(115 \mathrm{kV}\) class and higher have a voltage range factor \(\mathrm{K}=\) ____________, such that their symmetrical interrupting current capability remains constant.
-
The most important job of the Federal Trade Commission today is to _______. a) prevent false and deceptive advertising b) break up unlawful trusts c) issue cease-and-desist orders when...
-
When calculating symmetrical three-phase fault currents, only _________ sequence network needs to be considered.
-
Cash is being used less frequently to settle debts. Technological developments and environmental impacts have resulted in the way in which payment is made for goods and services changing. Many retail...
-
Appliance for Less is a local appliance store. It costs this store $27.13 per unit annually for storage, insurance, etc., to hold microwave in their inventory. Sales this year are anticipated to be...
-
Which of the following is NOT a magnetic dipole when viewed from far away? a) A permanent bar magnet. b) Several circular loops of wire closely stacked together with the same current running in each...
-
If you buy a computer directly from the manufacturer for $3,500 and agree to repay it in 60 equal installments at 1.75% interest per month on the unpaid balance, how much are your monthly payments?...
-
Find the producers' surplus at a price level of $55 for the price-supply equation p=S(x) =15 + 0.lx+0.003x 2
-
In Problem, find each derivative and simplify. d. logs(5*-1) dx
-
Consider the situation illustrated in Figure 25. 11. A positively charged particle is lifted against the uniform electric field of a negatively charged plate. Ignoring any gravitational interactions,...
-
A positively charged particle is moved from point A to point B in the electric field of the massive, stationary, positively charged object in Figure 25. 12. (a) Is the electrostatic work done on the...
-
Figure 25. 13 shows both the electric field lines and the equipotentials associated with the given charge distribution. (a) Is the potential at point A higher than, lower than, or the same as the...
Study smarter with the SolutionInn App