Skip to main content
Loading Explore guides…
Confidence Interval · Acedra
Home
Explore
Statistics
Confidence Interval
Sign in to save
Chat
If YouTube asks you to sign in, open the video on YouTube.
Watch on YouTube
Reload player
Transcript
190 segments
Copy
Hide video
0:00
all right so what I want to start off with today is doing a simulation again to help us understand the content the content we want to understand using simulation
0:13
is the idea of a confidence interval to start off with today and hopefully we'll also understand hypothesis testing we will introduce hypothesis testing today so let's start simple let's again assume we're in a situation where the population standard deviation is known
0:31
so we're going to do a in general 100 times 1 minus Alpha percent confidence interval CI
0:43
to estimate something to estimate
0:48
a population mean new
0:54
most commonly the percentage people use is 95 percent that's the most common percent to use it's not like you have to use 95 it's just the most common thing people use people are kind of stuck on it you should be able to deal with 99 or 90 or even 98.7 percent theoretically
1:14
if this is 95 that means 1 minus Alpha is 0.95
1:20
and so Alpha itself is 0.05 Alpha is called the level of significance the the entire thing here is called the confidence level confidence level and Alpha itself is called the level of significance
1:39
Alpha itself has more meaning in the context of hypothesis testing which again we're going to start talking about hypothesis testing today
1:51
as you know what does a level of significance really represent
1:57
we're trying to estimate a population mean mu and the simplest case is going to is to go ahead and assume assuming that the population standard deviation Sigma and therefore also the variance Sigma squared is known
2:16
okay it's just a simpler calculation in that setting because we don't have to worry about the T distribution it's not really realistic in most real life applications because in real life applications if you don't know mu why would you know Sigma
2:34
right in most in most real life applications you wouldn't know either one but to keep things simple
2:42
we go ahead and at first assume we know Sigma and the formula written with capital x bar instead of lowercase x bar
2:54
is really a formula involving random samples a statistic that is a random variable it's got a distribution X bar is a point estimator right our favorite Point estimator
3:09
it's a statistic it can be computed from a random sample but a random sample
3:15
in the abstract is just a list of random variables and random variables with the same distribution
3:23
and so this has got a distribution as well that's important it's sometimes called a sampling distribution I haven't really emphasized that as much as I should have it's often called a sampling distribution
3:35
it's a point estimator it's unbiased right
3:38
expected value of x bar is Mu the mean of the mean is the mean that's a big big deal
3:45
okay fundamental thing to know a lot of statistics but we want to widen it to an interval estimator
3:52
call the confidence interval we need a margin of error
3:58
Dr Wetzel usually calls it capital E for error some books call it m for margin of error or maybe m-e-m-o-e for margin of error MO okay it doesn't matter
4:13
I wrote it as a capital either as if it's a random variable and that is the case in the case where Sigma is not known and you have to use S the pop the sample standard deviation but when we know Sigma it's actually not a random variable maybe I should have used a lowercase e
4:32
the formula for that margin of error is z sub Alpha over 2 times Sigma over square root of n
4:44
Sigma over square root of n by the way
4:51
is the standard deviation of X bar you could call that Sigma sub X bar
5:01
root of the variance of X bar you might remember I hope you remember back in chapter seven we had a formula for the variance of X bar to be Sigma squared over n and we're taking the square root of that
5:16
we've got a name it's sometimes called the standard error
5:20
standard error actually the name standard error is inconsistently applied sometimes
5:31
um here the standard error I'm I'm using this name to represent the standard deviation of X bar meaning standard deviation of its sampling distribution
5:42
however the word standard error sometimes applies even when you use S instead of Sigma even when you use a statistic here instead of a parameter you get the distinction Sigma is a parameter it's a fixed but unknown perhaps unknown number we're pretending we know it now N is a fixed sample size this is a number if I use an S there instead of a sigma a capital essay then it becomes a statistic
6:10
and it's just an estimator for this thing
6:18
as usual when the subscript there is for the Z that subscript represents the area to the right of that Z value if this is a standard normal distribution right here n01
6:33
then Z sub Alpha over 2 is the number along the axis so that the area under the curve to the right of that number is Alpha over 2. that's shaded area is Alpha over two so again in the most common case where Alpha is .05 if Alpha is .05 that means Alpha over 2 is .025 and Z sub point zero two five is a number you should probably remember until the day you die is 1.96 approximately
7:09
right if you do statistics every day you should remember that for the rest of your life
7:17
confirmation go to the distribution menu on your calculator go to in the norm
7:24
area 0.975 that's a CDF value and area to the left if I want the area to the right to be 0.025
7:33
1.96 very close
7:41
but if you had some other value of alpha then you'd get a different number
7:48
let's try to understand this via simulation now
7:55
let's say we're simulating from a uniform distribution
8:03
or simulate
8:07
sampling
8:11
from a uniform Distribution on the interval from 0 to 10 like we did before
8:21
with this we'll go ahead and use a spreadsheet to keep it simple
8:26
if we assume the spreadsheet's random number generator is good
8:32
then we're essentially pretending we know the exact mean and the exact standard deviation in fact
8:40
mu would be 5 right halfway between the endpoints
8:46
what's the variance Sigma squared look in the table
8:50
for uniform distribution it's B minus a squared over 12. you could confirm that by integration and the 12 seems kind of mysterious why is it a 12.
9:04
that's just the way it turns out you can confirm it by integration
9:09
so in this case that's going to be 10 squared over 12 100 over 12.
9:15
which you could also reduce if you liked 25 thirds oh that be 8.3 repeating and then the standard deviation is going to be the square root of that which will be a little less than 3.
9:31
oops 25 over 3 up 8.3 repeating take the square root of that about 2.887 let's round it to that 2.887
9:47
. so we're pretending we know effectively what Sigma is here
9:53
what do I want to do to do the simulation to help us understand this
10:01
I'm going to use Rand on the spreadsheet to get random samples from this distribution
10:08
samples a certain size and what should I use for N I could use anything I want let's make it not be too big so I'm not copying and pasting way down the spreadsheet maybe n is 10 or something
10:21
and we'll see we'll compute this interval and see if it captures the true mean or net
10:28
let's do a 95 interval if I do that the idea is it should capture the true mean about 95 of the time
10:36
let's see if that holds
10:41
it's probably going to be easier actually this in this case if I do the random sampling across the
10:47
rows instead of columns because I'm going to want to calculate the X bars and the confidence intervals and be able to go down
10:56
various rows to see whether they capture you or not so 10 times Rand is what I can use
11:09
epic enough you guys in back okay
11:16
and don't be bothered by the fact that the numbers change all the time
11:23
random samples of size 10 say n is 10 a b c d a b c d e f g h i j go to column J here
11:40
I memorized that e is the fifth letter in the alphabet but I haven't memorized that J is the tenth I should do that for my own okay
11:48
there's a random sample of size 10 from the u010 distribution
11:55
what's the mean
12:04
again it changes all the time that time it's 5.76 that's a that's a point estimate that's an observed value of the point estimate or it's a little X bar an observed value of capital x bar
12:20
and we can do that over and over again let's do so it's a random sample of size 10 but let's do this sampling oh a hundred times so I got a hundred samples of size 10.
12:39
here we go
12:44
those are the point estimates let's widen these to interval estimates
12:53
a left end point and a right end point okay
12:59
observe value and I use the actual observed value of x bar
13:05
minus 1.96 I'm doing a 95 confidence interval here times Sigma was the square root of 8.3 repeating that was the 2.887 divided by square root of n n is 10.
13:27
that'll be the left endpoint
13:33
the right endpoint will be something similar except the plus sign right
13:45
Sigma again is about 2.887
13:50
divide by square root of 10 . okay this this particular interval 3.67 to 7.25 is capturing the true mean five
14:03
it is centered at 5.46
14:08
can I calculate I hope uh wait a minute that doesn't look right what did I do wrong
14:21
uh uh
14:25
or is it right maybe okay I'm just double checking the margin of Errors the same on either side so 7.25 minus 7.25 minus uh 5.46 is what I'm doing in my calculator right now gives 1.79 and 5.46 minus 3.67 is also 1.79 okay margin of error for this particular one is 1.79 in fact
14:54
because Sigma I'm pretending is known to be 2.887
15:00
the margin of error here is not going to change but X bar does change so the interval changes
15:08
if we don't know Sigma though and we got to use S then the margin of error can even change
15:16
copy and paste these down
15:22
synthesis these are 95 confidence intervals about 95 percent of them should contain five and five percent will not there is one that does not
15:37
maybe there's a fancy way to use countif to count the number that do not but uh I'm not quite sure how let's see if I can just visually do it there's one
15:52
I'm probably going too fast there's a second one
15:55
you got to look at both columns that's the hard part here
16:00
oh almost there but not quite
16:06
oops ah
16:09
I don't know what happened there there's a third one
16:19
oh sorry my scrolling is not doing so hot here so we're up to three of them that do not contain five
16:29
uh I think oh there's a fourth one just barely
16:39
there's a fifth one right there
16:43
is going to be exactly five not necessarily right because they're simulation randomness
16:52
there is a sixth one so it looks like 94 of them contain five in this case and six percent if not
17:00
it's all approximations right because of randomness
17:07
that's the idea behind the confidence level when you do the simulation 95 percent
17:13
approximately will contain mu can the 95 be interpreted as a probability um yes and no
17:24
you could interpret the 95 confidence level as a probability if you are thinking about it before the fact I am about to do some random sampling and compute a confidence interval and I would like to be a 95 consequence interval and I'm wondering before the fact what are the chances that it will contain you
17:42
if you're doing a 95 confidence interval you would say the probability is 0.95
17:48
but when you actually do the interval when you gather the sample and compute it get an interval
17:56
and you look at that interval and say what are the chances that that mu is in there
18:01
you can't really assign a probability to that
18:05
I mean if somebody knows Mew and you want to talk about betting odds I mean effectively you could sort of think of it as a probability but once you've done the sampling all the randomness is gone probability is about Randomness before the fact
18:22
so we usually avoid thinking of the confidence levels of probability
18:27
we interpret it as well a level of confidence I'm 95 confident in this interval I'm pretty sure
18:36
but since we're always thinking about it after the fact we don't typically think of it as a probability
18:44
but if you do simulation if you imagine doing random sampling from the same population with the same sample size over and over and over again you could say about 95 of the intervals will contain you and and five percent will not but you never know which ones do and which ones don't yeah right I'm I'm pretending I know the population here I'm assuming this is an accurate simulator
19:09
with Rand
19:12
I'm pretending I know the true mean is five is it really random though is the spreadsheet really random
19:19
that's not what you mean some people call technology things like this on spreadsheets pseudo random is technically speaking they they are generating their numbers by non-random processes and if you want to be technical about it but it simulates randomness
19:37
and so you can never quite be sure that it's quote unquote perfect or even necessarily close to perfect
19:45
it's usually good enough though if it's pretty good and I guess we trust it basically can I clarify anything there
19:58
what if we had used the sample standard deviation in each case
20:11
100 times 1 minus Alpha percent confidence interval to estimate mu
20:21
sometimes you just say form you but in reality it's to estimate you when you're in the more realistic situation where Sigma is unknown
20:35
then the formula is X bar cat notices Capital plus or minus t sub Alpha over 2 times capital S over square root of n that's capital s
20:51
both the point estimator in the center of the interval and the margin of error are random variables statistics that can be computed from a random sample and therefore are random variables X bar has a distribution by the central limit theorem it's approximately normal even if your population is not normal as long as n is large enough s has a distribution is s's distribution normal can't be exactly normal because s can't be negative could it be approximately normal Maybe
21:27
n is large enough again is there a central limit theorem for S we won't get into that at the moment
21:37
where you compute the T value based on a certain number of degrees of freedom which you know sometimes we call Little gamma sometimes I call it DF for degrees of freedom it's n minus 1.
21:54
that's the degrees of freedom this degrees of freedom always n minus 1 in statistics no it's not some people think it is because that's the most common thing to use
22:07
in statistics degrees of freedom is not always n minus 1.
22:14
chapter 10 we'll see examples where it's not chapter 11 we'll see examples which not
22:23
second most common thing to use is n minus two it depends on the situation okay
22:30
there are situations where it's n minus three or n minus 4 or n minus 5 or in chapter 10 actually something even more complicated something that involves the most uh
22:41
unpleasant formula and statistics called the Smith satirth rate formula that I I've hardly ever computed by hand because it's just it's almost impossible to use without making a mistake
22:52
you can look it up Smith's shatter three formula
22:58
DF is not always n minus one but in this context it is n minus one sample size minus one use a t distribution with n minus 1 degrees of freedom a t distribution has a PDF a density that looks like a normal distribution it's bell-shaped looks like a standard normal it's centered at zero
23:20
however it's not a normal distribution the formula for its PDF is different
23:28
you know a normal distribution the PDF formula involves e to a power looking in chapter seven and fixing the typos you see a t distribution does not involve e
23:44
I could call that a capital T sub n minus one
23:50
distribution what's different about it how compared to our normal it's a bit more besides having a different formula it's a bit more spread out
23:58
it's mean as zero but it's standard deviation is bigger than one it's not standard normal
24:06
and it's got heavier tails than a normal distribution does if you graphed a normal distribution on the same scale the standard normal distribution it would be a little taller and less spread out this would be a maybe a standard normal distribution in the same picture here
24:28
however as n gets larger
24:34
the black and the red curves get closer and closer together as the degrees of freedom gets larger
24:40
the black curve looks more and more like a normal curve you could say in the limit as n goes to Infinity they they merge they approach each other
24:52
so when that is large you can kind of get away with using a normal distribution if you really wanted to and it would be a pro give you approximately the same answer
25:08
so
25:11
again let's let's use the calculator to find T sub Alpha over 2 for example if Alpha is
25:18
0.05 so Alpha over 2 is 0.025 and we're after Little T sub .025 related to our simulation n is 10 for our simulation so if we use degrees of freedom to be 9 what will we get here
25:42
need n for t
25:47
an area of 0.975 degrees of freedom is 9. should be a bit bigger than 1.96
25:57
2.262
26:07
so I'm about to use this formula here on the spreadsheet with that value of T 2.262 but remember s is still a random variable the different samples of size 10 will have different observed values of s now they could call Little F's in each case so again not only is the point estimate going to be a random variable but the margin of error is going to be a random variable in this case I'm more justified in calling this entire thing a capital e
26:37
of course you'd want to use avoid using lowercase e anyway because that might make people think it's the number e which is not in
26:51
the table in the back of the book
26:56
for the T distribution if you wanted to use that to find the T value here
27:02
T distribution table where is it okay here it is it's table five
27:08
no that standard normal excuse me Table Six starts on page 699 goes over a couple pages
27:18
there's gamma that's the degrees of freedom go to nine degrees of freedom these numbers are areas to the left instead of areas to the right
27:28
so Alpha is .05 so that Alpha is over 2 is .025 means we use 0.975 there's 2.262
27:47
sorry
27:51
so let's use that now in the spreadsheet
28:01
we're still using the observed values of X bar from column l
28:10
of course the numbers are going to change again so now I subtract 2.262
28:18
times not
28:21
the 2.887 anymore right that was Sigma
28:25
but instead The observed value of the standard deviation the stdev don't put a p on it
28:36
leave the P off
28:45
still divide by square root of 10.
28:52
notice for this particular sample here that I I haven't entered this yet where the mean was 5.4776 the left endpoint when we use Sigma was 2.887 is 3.688 but this left endpoint is 3.486 lower
29:12
because the margin of error is bigger here because 2.262 is bigger than 1.96 that's probably the main reason it's lower the standard deviation could be smaller than 2.887 I'm not figuring it out here I guess
29:30
explicitly I'm not showing it anywhere
29:37
actually maybe it would be good to see the standard deviation in each case
29:42
a separate column here
29:46
the different samples are going to give you different standard deviations
29:53
their sample standard deviations their estimators for 2.887 observe estimates I should say
30:02
although remember s is not unbiased for Sigma right s squared is unbiased for Sigma squared s itself the standard deviation sample standard deviation is not unbiased for Sigma the population standard deviation unfortunately but uh I guess we don't worry about it
30:22
again T is two point two six two I'm just going to use S from column P divide by square root of 10.
30:34
huh okay there I got there I'm getting a bigger number 3.73 than 3.64 . even though 2.262 is bigger than 1.96 I guess well yeah this s is less than 2.887 significantly enough to make this left endpoint not smaller than this one I think usually it will be smaller
30:58
and in this case it's smaller once I entered it things changed smaller than that
31:10
2.262
31:13
there's my value of s divided by square root of 10. again things will change again
31:23
so again column p is the S values based on those S values we get a left endpoint and a right endpoint
31:35
somebody email me right now remind me to actually share this file with you I don't want to go ahead and count how many of these contain or don't contain five anymore
31:44
somebody could email me right now I don't know why it's dividing by zero there
31:52
so did I
31:58
oh thank you yeah
32:11
so used to going down columns instead of across rows
32:16
Okay so it should be the case that around five percent of these intervals do not contain five
32:26
about 95 of them should
32:31
I'm not going to go ahead and count them this time
Here to help you learn
Sign in to keep a private conversation with your course tutor.
Ask me anything about the material…
Sign in to chat