A confidence interval for your random heights
(5pts)
In this problem, we're going to return to our fun web program that generates random CSV data for people. Recall that you can access it via Python like so:
%matplotlib inline
import pandas as pd
df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=mark')
df.tail()
first_name | last_name | age | sex | height | weight | income | activity_level | |
---|---|---|---|---|---|---|---|---|
0 | Donna | Dinan | 35 | female | 65.37 | 164.26 | 1947 | high |
1 | Antonia | Davis | 39 | female | 64.95 | 140.40 | 2188 | none |
2 | Stephanie | Buss | 30 | female | 60.75 | 181.83 | 18108 | high |
3 | Wendell | Elmore | 26 | male | 64.68 | 157.90 | 1935 | moderate |
4 | Nina | Mcilhinney | 21 | female | 59.94 | 163.38 | 5675 | none |
Also recall that the data is randomly generated but the random number generator is seeded using the username
query parameter in the URL. Thus, if I execute that command several times, I get the same result every time. That result depends upon the username
, however. Thus, if you do it with your forum username
, you'll get a different result. Thus, we all have our own randomly generated data file!
The problem: Using the code above with your username
, generate your data file and then
- Compute the average value of the heights in your data (which you've done before),
- the standard deviation of the heights in your data,
- the standard error of the heights in your data,
- the margin of error to use the heights in your data to compute a $(100-s)\%$ confidence interval (where $s$ is your special number), and
- the resulting $(100-s)\%$ confidence interval for height
Be sure to include both the code that you typed, as well as the results in your post.
Comments
%matplotlib inline
import pandas as pd
df = pd.read_csv('https://www.marksmath.org/cgi-bin/random_data.csv?username=jordan')
df.tail()
heights=df.height.sample(100,random_state=1)
xbar=heights.mean()
xbar
%66.73939999999997%
s= heights.std()
s
%4.122285043492017%
se = s/sqrt(100)
se = (s/10)
se
%0.41222850434920166%
from scipy.stats import norm
z=norm.ppf(0.045)
z
%-1.6953977102721358%
from scipy.stats import norm
z= norm.ppf(0.995)
z
%2.5758293035489004%
me= z*se
me
%1.061830261260809%
ci= [m-me, m+me]
ci
%[177.91816973873918, 180.0418302612608]%
1) Avg Values
65.5548
2) Std Deviation
4.113876610652872
3) Std Error
0.4113876610652872
4) Margin of Error
z = -1.6953977102721358
zstr=-z
zstr
zstr=1.6953977102721358
0.6974656986042974
5) Confidence Interval for 91%
[64.8573343013957, 66.2522656986043]
mean: 66.3
sd: 3.89
se: .39
margin of error: .79
z*: 2.05
confidence interval for 96%: (65.51,67.09)
Code for my data table:
1.) Average Value of the Heights:
= 66.30110000000002
2.) Standard Deviation of the Heights:
= 3.7302560084917624
3.) Standard Error of the Heights:
= 0.37302560084917624
4.) Margin of Error:
= 0.7460512016983525
5.) Confidence Interval for Height:
= [65.55504879830167, 67.04715120169837]
6.) z* Multiplier:
I had a 94% CI, so my number was 6
= 1.880793608151251
1.
m= 66.20770000000003
2.
s= 3.490168255907652
3.
se= 0.3490168255907652
5.
ci= [65.30869223321172, 67.10670776678835]
First, I'll import my data and compute my mean and standard deviation:
[66.49599999999998, 3.9782326922309807]
Thus, my standard error is:
0.39782326922309807
and my %z^*%-multiplier is 1.96 since:
-1.9599639845400545
1.) Mean:
65.35810000000001
2.) Standard Deviation:
3.701679306324183
3.) Standard error
0.37016793063241826
4.) Margin of error
0.7403358612648365
5.) Confidence Interval
[64.61776413873517, 66.09843586126485]
mean=67.02449999999999
standard deviation=3.8097767306462633
standard error=0.3809776730646263
0.9619022326935374
z*=1.7732002261111544
Margin of Error=0.6755496960214968
Confidence Interval=[66.3489503039785, 67.70004969602148]
This is the code importing my data along with the mean and standard deviation :
[65.81690000000002, 3.854679615661196]
The standard error is: 0.3854679615661196
The z multiplier is: 2.2
-2.1700903775845606
The margin of error is: 0.8480295154454632
The confidence interval is: [64.96887048455456, 66.66492951544548]
1+2) mean and standard deviation
[66.81249999999999, 4.248674273324336]
3) standard deviation
0.4248674273324336
4) margin of error
0.8497348546648672
5) confidence interval
[65.96276514533511, 67.66223485466486]