# Example code for finding (standard) normal probabilities in R # The command pnorm computes normal probabilities # It computes the probability that a standard normal r.v. is less than (or equal to) # a certain value. So R gives us P(Z < value), whereas Table II in the book gives # us P(0 < Z < value) # Suppose our random variable Z is standard normal # Let's answer the following questions which were given in class # 1. What is the probability Z is between 0 and 1.24? pnorm(1.24) - pnorm(0) # 2. What is the probability Z is greater than 1.24? 1 - pnorm(1.24) # 3. What is the probability Z is less than 1.24? pnorm(1.24) # 4. What is the probability Z is between -0.54 and 0? pnorm(0) - pnorm(-0.54) # 5. What is the probability Z is less than -0.54? pnorm(-0.54) # 6. What is the probability Z is between -1.75 and -0.79? pnorm(-0.79) - pnorm(-1.75) # 7. What is the probability Z is between -0.79 and 1.16? pnorm(1.16) - pnorm(-0.79) # What if X is normal with mean 266 and standard deviation 16 (like the pregnancy # example in class)? If you're clever, you can let R standardize for you, # as the eighth example here will show: # 8. What is the probability X is between 260 and 280? pnorm((280-266)/16) - pnorm((260-266)/16) # or alternatively: pnorm(280,mean=266,sd=16) - pnorm(260,mean=266,sd=16) # Compare to the results we got in class using the tables # The difference is: R can do these for any values of Z