# Questions and Answers on Homework Assignment #4

#### HW#3 is due on paper in class, Monday 19 October 2009

Question text is in black, my answers in blue.

• Question 4.1, posted 17 October: You say that our code for Problem 10.6.3 doesn't need to compile. Do I need to worry about numerical precision and integer overflow?

No, you can implement this with `int` and `double` variables. The numerical precision problem is that the true probabilities are fractions and the `double` values you'll use are thus approximations. When you add up lots of numbers that are slightly off, the errors can accumulate. But here you are only adding a few thousand numbers and the error shouldn't be significant. The problem of integer overflow is that if you deal with numbers larger than 2 billion or so the computer wraps around and gets wrong answers. I don't see why you would want such large numbers for this problem, particularly if you deal with all the probabilities as `double` values, but in any case we won't worry about overflow when grading your paper code.

• Question 4.2, posted 17 October: On the same problem, do I have to write methods for factorial, falling powers, binomial coefficients, Bernoulli probabilities, and so forth in the code I submit?

No, for the homework you can assume that you have a package lying around that does all this stuff, so you can just call methods like `binom(n, k)` or `bernoulli(n, i, p)` and not even worry precisely what they are called. The point of this problem is to show that you can solve the baseball problem using the material from the chapter.

However, coding up these methods on your own is a good way to internalize their definitions, and would be fair game as a test question!

• Question 4.3, posted 17 October: I'm still confused about 10.5.3, because I really hated MATH 132.

First, the standard Poisson variable is equal to 0 with probability 1/e, equal to 1 with probability 1/e, equal to 2 with probability 1/2e, equal to 3 with probability 1/6e, and in general equal to 1 with probability 1/(i!)e. The expected value of P is an infinite sum, 0(1/e) + 1(1/e) + 2(1/2e) + 3(1/6e) + ..., and this is a sum that you should recognize. To get the variance, you need to also calculate the expected value of P2, which is another infinite sum, 02(1/e) + 12(1/e) + 22(1/2e) + 32(1/6e) + ..., that is harder but still possible to evaluate just knowing the basic fact that ex is the sum for all i of xi/i!. (The hard part in MATH 132 was seeing why this is true using Taylor series, but we don't need to get into that.)