Project 39: Two-Prop Z Interval

Suppose we randomly sampled 100 adult females and 100 adult males and asked them if they are on Instagram.  Forty-five of the males said they were on Instagram and sixty of the females said they were on Instagram.  We want to construct a 98% confidence interval for the true difference in the proportions of males and females who are on Instagram.


Since both sampling distributions are approximately normal (45, 55, 60, 40 are all at least 10) then the sampling distribution for the difference in sample proportions is approximately normal.  Below are the calculations for the confidence interval.


phatM = 45/100 = .45

phatF = 60/100 = .6

statistic = phatM - pHatF = -.15

standard error = sqrt(.45*.55/100+.6*.4/100) = .07

critical value = 2.33 (based on .98 confidence level)

margin of error = .07*2.33 = .16

confidence interval = [-.15 - .16, -.15 + .16] = [-.31, .01]

We are 98% confident that the true difference in proportions in males and females who are on Instagram is between -.31 and .01.


Project 39: Variables 'x1', 'n1', 'x2', 'n2', 'confidenceLevel' have been initialized. There are also working methods called normalcdf and invNorm.

x1 is the number of successes of the first group (45 for the example above)

n1 is the sample size of the first group (100 for the example above)

x2 is the number of successes of the second group (60 for the example above)

n2 is the sample size of the second group (100 for the example above)

Note: Look back at projects 2-5 for additional explanation for the normalcdf and invNorm methods.

Task: Appropriately initialize the values of 'lower' and 'upper' that represent the lower and upper bound of the given confidence interval.

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0