STATS 1000 / STATS 1004 / STATS 1504 Statistical Practice 1 Practical Week 5 2015 Practical Outline In this practical, we will look at how to do binomial calculations in Excel. look at how to do normal calculations in Excel. Part I Learning about SPSS 1 Opening Excel First, start Excel by clicking on the icon at the bottom of your screen. (Or choose: Start>All Programs>Microsoft Office>Microsoft Office Excel 2007) 2 Binomial Calculations in Excel Binomial probabilities can be calculated in Excel using the built-in function BINOMDIST. The easiest way to calculate a single binomial probability is as follows. 1. Click on the Insert Function icon f x above the column names. 1
(Alternatively, from the Formulas menu, select Insert Function. ) 2. In the Insert Function dialog box, select Category:Statistical, followed by Function:BINOMDIST. 3. Enter the required function arguments in the BINOMDIST dialog box before clicking on OK. Number s The number of successes, x. Trials The total number of trials, n. 2
cumulative = 1 cumulative = 0 0.3 0.3 0.2 0.2 0.1 0.1 0.0 0.0 0 1 2 3 4 5 6 x (a) P (X x) orange boxes. 0 1 2 3 4 5 6 x (b) P (X = x) orange box. Figure 1: Difference between cumulative = 1 and cumulative = 0 Probability s The probability of success in a single trial, p. Cumulative 1(TRUE) or 0(FALSE) (See Figure 1). Enter 1(TRUE) if the value to be calculated is the probability of being less than or equal to the number given in Numbers s. Enter 0(FALSE) if the value to be calculated is the probability of being equal to the number given in Numbers s For example is X Bin(10, 0.5) and you want to calculate the probability that X is less than or equal to 2, then you would enter Number s 2 Trials 10 Probability s 0.5 Cumulative 1 3
Question If you toss a fair coin 10 times, what is the probability of no heads, 3 or less heads, at least one head, between 1 and 3 heads (inclusive)? Solutions Let X be the number of heads, then X Bin(10, 1/2) P (X = 0) = BINOMDIST(0,10,0.5,0) = 0.0010 P (X 3) = BINOMDIST(3,10,0.5,1) = 0.1719 P (X 1) = 1 P (X = 0) = 1 BINOMDIST(0,10,0.5,0) = 0.9990 P (1 X 3) = P (X 3) P (X = 0) = BINOMDIST(3,10,0.5,1) - BINOMDIST(0,10,0.5,0) = 0.1709 3 Normal Probabilities Normal probabilities can be obtained in Excel using the built-in function NORMDIST as follows. 1. In the Insert Function dialog box, select Category:Statistical, followed by Function:NORMDIST (Note: not NORMSDIST). 2. Enter the required function arguments in the NORMDIST dialog box before clicking on OK. x The real number x. Mean The real number µ. Standard dev The real number σ > 0. Cumulative You should enter 1(TRUE) as we require the cumulative distribution function not the probability density function. 4
The value calculated is the probability that X is less than or equal to the number x for X N(µ, σ) (See Figure 2). X Figure 2: P (X x) for normal distribution (orange area). Note: a separate function NORMSDIST is also provided. This function has just a single argument z and calculates the probability that the standard normal random variable is less than or equal to z. It is equivalent to using NORMDIST with µ = 0 and σ = 1. The inverse cumulative distribution function can also be calculated in Excel. The inverse cumulative distribution function gives the constant c such that probability that X is less than or equal to c is equal to some given probability p. The Excel function to do this is NORMINV. It is used as follows: 1. In the Insert Function dialog box, select Category:Statistical, followed by Function:NORMINV (Note: not NORMSINV). 2. Enter the required function arguments in the NORMINV dialog box before clicking on OK. Probability The number p with 0 < p < 1. Mean The real number µ. Standard dev The real number σ > 0. 5
The value calculated is the solution x to the equation P (X x ) = p for X N(µ, σ). Question The weight of cats is normally distributed with a mean of 4kg and a standard deviation of 0.5kg. What is the probability of a randomly selected cat weighs less than 3kg? a randomly selected cat weighs more than 4kg? a randomly selected cat weighs more than 4kg or less than 3kg? a randomly selected cat weighs between 3 and 4kg? What weight c is such that 10% of all cats are less than this weight? Solutions P (X < 3) =NORMDIST(3,4,0.5,1) = 0.0228. P (X > 4) = 1 P (X 4) = =1 - NORMDIST(4,4,0.5,1) = 0.5 P (X > 4 or X < 3) = P (X > 4) + P (X < 3) =NORMDIST(3,4,0.5,1) + (1 - NORMDIST(4,4,0.5,1)) = 0.5228. P (3 X 4) = P (X 4) P (X 3) =NORMDIST(4,4,0.5,1) - NORMDIST(3,4,0.5,1) = 0.4772. Use NORMINV(0.2,4,0.5) to give the answer 3.58 kg Part II Assignment Questions Using excel answer the following questions. 1. A multiple choice test has 15 questions. Each question has 5 candidate answers of which exactly 1 is correct. Suppose a certain student answers each question by randomly choosing one of the five answers. Make sure you have checked your answers with the lab tutor. Let X be the number correctly answered. (a) What is the distribution of X? (b) Find the probability the student gets exactly 4 correct answers. 6
Solutions No solutions as assignment questions (c) Find the probability the student gets at most 4 correct answers. (d) Find the probability the student gets 6 or more correct answers. (e) Find the probability the student gets between 4 and 10 correct answers (inclusive). 2. The weight of mice is known to be normally distributed with a mean of 10grams and a standard deviation of 1gram. (a) What is the probability that a randomly selected mouse weighs less than 10 grams? (b) What is the probability that a randomly selected mouse weighs more than 11 grams? (c) What is the probability that a randomly selected mouse weighs between 8 and 12 grams? (d) What is the weight c such that the probability that a randomly selected mouse weighs less than c is 0.01? Part III Appendix A Probability notation X Bin(n, p): The random variable X has a binomial distribution with the number of trials n and the probability of success p. X N(µ, σ): The random variable X has a normal distribution with a mean of µ and a standard deviation of σ. P (X = x): The probability that the random variable X is equal to x. P (X x): The probability that the random variable X is equal to or less than x. 7