Giter Club home page Giter Club logo

solved-ee381-lab-5-confidence-intervals's Introduction

Download Link: https://assignmentchef.com/product/solved-ee381-lab-5-confidence-intervals
Assume that you are measuring a statistic in a large population of size N. The statistic has mean µand standard deviation σ. Drawing a sample of size n from the population,

produces a distribution for the sample mean ( X ) with:

2 2 σ2 σ

E X[ ]=µ µX and E X[( −µ σX ) ] = X = ⇒σX = n

In this project we will explore the relation of X to the population mean µ.

  • As a first example consider a barrel of a million ball bearings (i.e. population size

N =1,000,000) where someone has actually weighed all one million of them and found the exact mean to be µ=100 grams and the exact standard deviation to be σ=12grams. This is obviously an unrealistic assumption, but assume for the time being that these parameters have been measured exactly.

  • Now pick a sample of size n (for example n=5 ) of bearings from the barrel, weigh

X X1 + + + +2 X X3 4 X5

them and find the mean of the sample, X5 = .

5

  • Next take a larger sample (for example n=10) and find the new mean

X10 = X X1 + + +2 L X10 .

10

  • Continue this process for larger and larger n , until n=
  • Plot the points (n X, n)using a point marker (for example a blue ‘x’) as shown in Figure 1.
  • Next for each value of n , calculate the standard deviation of the sample from σ σ= and plot:

σ

  • The values of µ±96as a function of n , shown as the red curves in

Figure 1a. These curves define the 95% confidence interval, which means that approximately 95% of the sample means will fall within the two red curves in Figure 1a. This can also be visually confirmed by looking at how many of the sample means fall outside of the red curves (approx. 5%).

σ

  • The values of µ± 58as a function of n , shown as the green curves

in the Figure 1b. These curves define the 99% confidence interval, which means that approximately 99% of the sample means fall within the green curves in Figure 1b.

(a) (b)

Figure 1. Sample mean as a function of the sample size

0.2.

0.3. Using the sample mean to estimate the population mean

In reference to the previous section, it is obviously unrealistic to think that anyone actually measured the exact mean and standard deviation of all one million ball bearings. More realistically, you would not have any idea what the mean or standard deviation was, and you would need to weigh random samples of different sizes (for example n= 5, 35, or 100bearings) and then draw reasonable conclusions about the weight

distribution of all one million bearings.

To simulate this problem, generate a barrel of a million ball bearings with weights normally distributed, with a mean µ and a standard deviation σ.

As an example, take a sample of n bearings from the population of N =1,000,000. Then calculate the mean of the sample:

X X1 + + +2 L Xn

X =

n

The standard deviation of the sample mean can be calculated by:

Sˆ ˆ =(X X− )2 + (X X )2 + +L (X X )2 1/2 σn = , where S  1 2 n

n−1 

The question is: Can the value of X , which is calculated for a sample of size n , be used to estimate the mean µof the population of N =1,000,000bearings?

The answer is given in terms of confidence intervals, typically the 95% and 99% confidence intervals.

Large samples (n≥ 30).

X −µ

Consider the standardized variable z =. Based on the Central Limit Theorem, it is σn

known that for large samples the standardized variable z will approach the normal distribution.

The 95% confidence interval for large samples. The 95% confidence interval is determined by the critical values [−zc ,zc ]such that

P{− < <zc z zc}= 0.95

From the tables of the normal distribution it is seen that these critical values correspond to zc =1.96 and − −=zc 1.96. Hence:

P z{− < <c z zc}= 0.95

which is written as

X −µ 

P 1.96− < 1.96<  0.95= P X{⇒ 1.96σ µ−n < < +X 1.96σn} 0.95=

 σn

Sˆ Sˆ 

P X −1.96 < < +µ X 1.96 = 0.95



Sˆ If you define: µLower = X 1.96− and µUpper = X 1.96+ , then the above equation is

written as:

P{µ µ µLower < < Upper}= 0.95

This equation can be interpreted as follows:

Based on a sample of size n , we are 95% confident that the mean µof the population

lies in the interval [µ µLower , Upper].

Another way to interpret this statement is:

  • Obtain a large number of different samples, of size n each

Sˆ

  • For each of these samples calculate X and σn =
  • For each of these samples generate the corresponding intervals

[µ µLower , Upper]

  • Then the mean µof the population will be contained in 95% of these intervals

For example if you obtain 500 samples of size n each, and you create the corresponding 500 intervals [µ µLower , Upper], then 475 of these intervals (95% of 500) will contain the population mean µ.

The 99% confidence interval for large samples. Similarly, the 99% confidence interval is determined by the critical values [−zc ,zc ]such that

P{− < <zc z zc}= 0.99

From the tables of the normal distribution it is seen that these critical values correspond to zc = 2.58 and − −=zc 2.58.

Sˆ Sˆ

Hence, if you define: µLower = X 2.58− and µUpper = X 2.58+ , then you can write:

P{µ µ µLower < < Upper}= 0.99

which can be interpreted as follows:

Based on a sample of size n , we are 99% confident that the mean µof the population

lies in the interval [µ µLower , Upper].

Small samples (n< 30).

X −µ

When the sample size is small, the standardized variable does not approach the σn

normal distribution, since the Central Limit Theorem does not hold for small n .

X −µ

In this case the standardized variable T = follows the Student’s t distribution σn

with ν=n 1− degrees of freedom.

The 95% confidence interval for small samples. The 95% confidence interval is determined by the critical values [−tc ,tc ]such that

P{− < <tc z tc}= 0.95

Note that the critical values [−tc ,tc ]depend on two values: (i) the probability value (0.95) and (ii) the degrees of freedom (ν).

Example: sample size n= 5 . In that case ν= − =n 1 4 degrees of freedom. For the 95% confidence interval, the critical value is: tc = t0.975 2.78=, as seen from the Student’s t distribution tables.

Sˆ Sˆ Hence, if you define: µLower = X 2.78− and µUpper = X 2.78+ , then the above

equation is written as:

P{µ µ µLower < < Upper}= 0.95

which can be interpreted as follows:

Based on a sample of size n=5, we are 95% confident that the mean µof the population

lies in the interval [µ µLower , Upper].

The 99% confidence interval small samples. Similarly the 99% confidence interval is determined by the critical values [−tc ,tc ]such that

P{− < <tc z tc}= 0.99

Example: sample size n=5 . In that case ν= − =n 1 4 degrees of freedom. For the 99% confidence interval, the critical value is: tc = t0.995 4.60=, as seen from the Student’s t distribution tables.

Sˆ Sˆ Hence, if you define: µLower = X 4.60− and µUpper = X 4.60+ , then the above

equation is written as:

P{µ µ µLower < < Upper}= 0.99

which can be interpreted as follows:

Based on a sample of size n= 5, we are 99% confident that the mean µof the population

lies in the interval [µ µLower , Upper].

  1. Effect of sample size on confidence intervals

Create two plots as in Figure 1a and Figure 1b, showing the effect on sample size on the confidence intervals.

The values of the following parameters have been provided to you:

  • Total number of bearings: N ;
  • Population mean: µ (grams);
  • Population standard deviation: σ (grams) ;
  • Sample sizes: n=1,2,L200

SUBMIT a report which includes the results and your code. You must follow the guidelines given in the syllabus regarding the structure of the report. Points will be taken off if you do not follow the guidelines.

2. Using the sample mean to estimate the population mean

(A) Perform the following simulation experiment. Use Table 1 to tabulate the results.

  1. Choose a random sample of n=5 bearings from the N bearings you created in the previous problem. Calculate the sample mean and the sample standard deviation:

X =1n X j and Sˆ =

n j=1

  1. Create the 95% confidence interval using the normal distribution to fill in the first two entries in the top row. You realize, however, that this is not an appropriate distribution to use because you have a small sample n = 5 30<

Sˆ Sˆ

[µ µLower , Upper− =] [X 1.96+ , X 1.96]

n

  1. Check if the confidence interval includes the actual mean µof the population of N bearings. If it does, then Step 2 is considered a success.
  2. The appropriate distribution for small samples (n≤30) is the t-distribution. Create the 95% confidence interval using the t-distribution with ν= − =n 1 4

Sˆ Sˆ

[µ µLower , Upper− =] [X t0.975+ , X t0.975]

n

At the 95% confidence level with ν=4 degrees of freedom, the value of t0.975 can be found from the tables, and it is seen to be: t0.975 = 2.78 . This is the value that will be used to determine the 95% confidence interval:

Sˆ Sˆ

[µ µLower , Upper− =] [X 2.78+ , X 2.78]. For a different sample size, the values of n

t0.975 will be different than the ones above. You should find these values from the tdistribution tables, and you should modify the confidence intervals accordingly.

  1. Check if the confidence interval includes the actual mean µof the population. If it does, then Step 4 is considered a success.
  2. Repeat the experiment for M =10,000times and count the number of successes.
  3. Enter the percentage of successful outcomes in Table 1.
  4. Repeat steps 1-7 above with n=5 and 99% confidence interval.
  5. After completing all of the above steps you will have filled out the first row of the table.
  • Repeat part (A) with n=40 using the normal distribution and the t-distribution to complete the second row of the table.
  • Repeat part (A) with n =120 using the normal distribution and the t-distribution to complete the third row of the table. You realize, however, that for a large sample (n>30 ) the t-distribution will be very close to normal, so the differences between Student’s -t and Normal will be minimal.

solved-ee381-lab-5-confidence-intervals's People

Contributors

programming-assignments avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.