Lab 4 Objectives:In this lab, we will use S-Plus to calculate probabilities of events for random variables distributed as binomial, Poisson, and normal. We follow Section 7.5 so that we can verify our calculations Binomial ProbabilitiesStart S-Plus and prepare your workspace as you see fit (see lab
1). If the Commands window is not already open, open it using
the tool bar button that looks like
We can use pbinom() ("p" for cumulative "p"robability) to calculate probability statements like on page 187.
For example, P(X >= 3) = 1 - P(X <= 2) is Let's make a plot of the Bin(5,.3) distribution (corresponding to Table 7.2, page 187, POB). Open a new data sheet by selecting Data > Select Data... and selecting Source New Data and typing, for example, binom7.2 for New Data Name. Press OK and a new graph sheet will appear. Name the first column x (or k as in the book) and second column, say, px. Type 0,1,2,3,4,5 as the values of x. You may want to change the data type of x to integer. We want to enter P(X=x) into the second column. Choose Data>Transform... from the menu and choose px as the Target Column and, for Expression, type pbinom(x,5,.3). Press OK. Now Graph>2D Plot... and in the Insert Graph dialog box choose High Density Line Plot(x,y1,y2,...) as the Plot Type. Leave other entries as they are and press OK. Now, for x Columns, type x and, for y Columns, type px. You may want to make the plot line thicker by modifying options from the Line tab. Press OK. The result is the graphical version of Table 7.2. Poisson ProbabilitiesNow we'll calculate some Poisson probabilities for X ~
Pois(2.5) as on pages 187-188. Use the function dpois()
to calculate P(X=x) for various values of x. For example, Normal ProbabilitiesWe'll use the function pnorm() for calculating normal
probabilities as on pages 189-191. Note that the function
dnorm() gives normal "d"ensity values, not
probabilities. First, a standard normal probability
calculation: Now, let's find the 95th percentile (quantile) of the normal
distribution N(63.9,2.6^2) using the quantile function:
Experiment with the above functions for the binomial, Poisson, and normal distributions. Be sure that you can do all of the above calculations (binomial, Poisson, normal) using the tables in the appendix of POB. |