/*------------------------------------------------------------- Homwework project #2 Due Thurs Jan 21, 1993 This file is /pub/st445/hw2 We will create our own binomial tables. You may recall that in n independent trials with probability p of success on each trial, the probability of getting r successes in the n trials is Pr(X=r) = n!/[r!(n-r)!]*p**r*(1-p)**(n-r) so if I have the probability for r-1, I can get the one for r by multiplying it by (n-r+1)/(r)*p/(1-p). Create the binomial tables for n=15 and p = .2, .5, and .7. Here is a hint : DATA BINOM; INPUT R @@; * @@ keeps us on the same line for reading data ; RETAIN; * RETAIN keeps the values as is for the next pass through the data instead of resetting them to missing. N= ; P = ; IF R= 0 THEN PROB = (1-p)**n; IF R>0 THEN PROB=PROB* ; CARDS; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; Tasks 1. Graph the binomial with 2 appropriate title lines. Use a LABEL statement to put "Probability of R Successes" on the Y axis and "Number of Successes = R" on the X axis. do a plot for each P and use a footnote to tell what P is used on each. 2. The normal is supposed to be a good approximation to the binomial. What is the appropriate mean_______________ and variance ____________ for each p? 3. Create R*PROB and R*R*PROB in the data. Print these and sum them using the SUM option of PROC PRINT. Explain how this relates to problem 2. Print ONLY the two new variables here and add appropriate titles and footnotes. 4. A child plays a video game at the arcade which consists of shooting at 15 targets. It costs 25 cents to play and the probability of hitting any one target is p and the shots are independent. He gets one ticket just for playing (0 hits) and the number of tickets doubles for each hit (he would get 8 tickets for 3 hits, for example). Tickets are taken to a booth for redemption. Find the mean number of tickets issued per play, that is, per quarter dropped into the machine. 5. (continuing) As the arcade owner, I do not want to loose money. When I redeem the tickets, how much value should I give back per ticket in order to make 5 cents on each quarter dropped into the machine? Calculate this for the three skill levels .2, .5, and .7 probability of hitting any one target. 6. (continuing) For your suggested ticket redemption value, what is the probability of a player in the high skill category getting more than 25 cents worth of tickets in a run? For questions 7-10 just use p=.2 if you like. 7. Returning to part 2, graph the normal as * and binomial as B overlaid on the same plot. You'll need to compute the normal ordinate f(Z) then use the OVERLAY option of PROC PLOT e.g. PROC PLOT; PLOT Y1*x Y2*X/overlay; 8. Plot the deviations of the true binomial probabilities from these normal curve values against R. 9. THe so-called normal approximation to the binomial involves computing the difference between PROBNORM( (R+.5-MU)/SIGMA ) and PROBNORM( (R-.5-MU)/SIGMA ) where PROBNORM is a function in SAS that calculates areas under the normal distribution. Calculate the approximation for each R. DO these sum to 1? Enclose a PROC PRINT to show it. If not, explain why they don't. Plot the difference between the binomial probability and the approximation versus R. Use appropriate titles labels and footnotes. 10. A power plant can be fined no more than 15 times per year based on 15 inspections for violations of the clean air act. The first fine is $5000, the second $10,000 the third $20,000 the fourth $40,000 etc. If a power plant has probability .2 of being fined on any given inspection, find the mean and variance of their yearly fine-paying expenses and find the most probable fine and its probability. What do you think about using FINE = 5000*(2**(R-1))*(R>0) ? What is the R>0 doing? */