CS计算机代考程序代写 Assignment 1 Instructions original

Assignment 1 Instructions original

CIS*3130 F21 Assignment 1 (original)
The Monte Carlo and Discrete State Simulators

Goals:
1. Experience using a simulation (in this case the Monte Carlo and Discrete State simulators)

to answer questions
2. Gain familiarity with Julia and with functional/OO “interface” style of abstraction

Questions
For the following questions: answer the question using the Monte Carlo simulator provided in class.

1) a) Using the Monte Carlo simulator from the class write simulation called DiceDiff that rolls two 6-
sided dice and returns the difference between the larger and smaller values. This simulation
would use a constructor DiceDiff().

b) Again, using the Monte Carlo simulator, write a second simulation SidesDiff. SidesDiff should
use a constructor SidesDiff(dieSide, die2Side = 0) that takes the difference between two die that
have differing number of sides. If die2Side is zero, use the value of dieSide as its value.

c) [bonus 5%] Create a type DDiff{s1<:Int, s2<:Int} and check whether there is a speed difference between this version, DiceDiff and SidesDiff. Note 1: Remember to provide testing results in your documentation (this applies to all questions). Note 2: To be backwards compatible with the previous version of this question, you may use a function diceDiff(args …) such that • diceDiff() returns a DiceDiff object, • diceDiff(die1Side, die2Side) returns a SidesDiff object However, the creation of this function is no longer required 2) a) Let's say you met someone with two children and who tells you that their oldest child is a boy, but did not mention the sex of the younger child. What are the odds that the other child is a girl? b) Now let's say you met someone who told you they had two children, and one of them is a girl, but did not happen to reveal the sex of the other child, nor the ages of either child. What are the odds that the other child is a boy? Answer these questions using the Event Processing state-simulator (repeated multiple times and reporting the mean and the 95% confidence intervals) and briefly discuss your results: Did you expect these outcomes or did they surprise you? Can you explain them? Etc. Hint1: Think carefully how you simulate the two situations. The situation for b is not the same as the situation for a Hint2: Especially think about the measures on the simulation Hint3: While the situations are different, the results may, or may not be, the same 3) A couple decided that they would continue to have children until they had at least one of each sex (boy and girl). Use a Basic State simulator 100,000 times and answer the following questions: a. What is the frequency (the percentage of times run) that they had at least {1, 2, 3, 4, 5} children respectively b. What is the frequency (the percentage of times run) that they had at exactly {1, 2, 3, 4, 5} children respectively c. On average how many children did the couple have? Produce the results with confidence intervals General Instructions You must create a document actually answering the questions. • Do not assume that if you hand in the code, that the TA will run it and answer the questions for you. In all cases explain the design of your simulations, i.e., the choices and assumptions you made to setup each simulation. For each question you can answer from the alternate version of the assignment, or this original version. You may mix and match. You only have to include one answer per question, not both. Submission Instructions Hand in the Julia you used to determine the answers. • Your code must use the Monte Carlo and Discrete State Simulators described in class, as provided on CourseLink. • Probability proofs may be used to check the validity of your simulators, but cannot be used as the answer to the question; a simulation must be done. All of your write-up (except program source code) should be either a Word document (.doc or .docx), a PDF document (.pdf), a text file (.txt) or a rich text file (.rtf). All answer files and .jl files should be bundled together into a single file using a standard archiving or compression program (such as .zip, .tar, .tgz, etc.) and submitted via CourseLink. Only hand in your “application” Julia source code. You do not have to hand in the Simulator code that was provided. Mark Breakdown Q1 Q2 Q3 All Total Correct Answer 4 6 6 16 Discussion 2 15 15 32 Simulation Design 10 15 15 40 Code Style 12 12 Total 16 36 36 12 100