# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
368 lines (337 sloc) 20.9 KB
 Standard deviation
randRange( 4, 6 ) randRange( 20, 50 ) animalAvgLifespan( 1 ) animalStddevLifespan( 1 ) $.map( randGaussian( TGT_MEAN, TGT_STDDEV, DATA_POINTS ), function( lifespan ) { lifespan = lifespan < 1 ? 1 : round( lifespan ); return randRange( 1, lifespan ); } ) roundTo( 1, mean( DATA ) )$.map( DATA, function( x ) { return roundTo( 2, ( x - MEAN ) * ( x - MEAN ) ); }) roundTo( 2, sum( SQR_DEV ) / ( DATA_POINTS - 1 ) ) roundTo( 2, sum( SQR_DEV ) / DATA_POINTS ) roundTo( 1, stdDev( DATA ) ) roundTo( 1, stdDevPop( DATA ) ) new Plural(function(num) { return i18n.ngettext("year", "years", num); }) i18n._("%(years)s old", {years: plural_form(YEAR, MEAN )}) i18n._("year") i18n._("years")

You have found the following ages (in years) of all DATA_POINTS plural_form(animal( 1 ), DATA_POINTS) at your local zoo:

What is the average age of the plural_form(animal( 1 )) at your zoo? What is the standard deviation? Round your answers to the nearest tenth.

Average age:
\quad mean( DATA ) years old

Standard deviation:
\quad stdDevPop( DATA ) years

Because we have data for all DATA_POINTS animal( 1 ) at the zoo, we are able to calculate the population mean (\blue{\mu}) and population standard deviation (\pink{\sigma}).

Because we have data for all DATA_POINTS plural_form(animal( 1 ), DATA_POINTS) at the zoo, we are able to calculate the population mean (\blue{\mu}) and population standard deviation (\pink{\sigma}).

To find the population mean, add up the values of all DATA_POINTS ages and divide by DATA_POINTS.

Find the squared deviations from the mean for each animal(1).

Age
x_i
Distance from the mean (x_i - \blue{\mu}) (x_i - \blue{\mu})^2
POINT plural( "year", POINT ) roundTo( 2, POINT - MEAN ) plural( "year", roundTo( 2, POINT - MEAN ) ) SQR_DEV[ i ] plural( "year", SQR_DEV[ i ] )^2

Because we used the population mean(\blue{\mu}) to compute the squared deviations from the mean, we can find the variance (\red{\sigma^2}), without introducing any bias, by simply averaging the squared deviations from the mean:

\red{\sigma^2} \quad = \quad \dfrac{\sum\limits_{i=1}^{\green{N}} (x_i - \blue{\mu})^2}{\green{N}}

\red{\sigma^2} \quad = \quad \dfrac{plus.apply( KhanUtil, $.map( SQR_DEV, function( x ) { return "\\color{purple}{" + x + "}"; }) )} {\green{DATA_POINTS}} \red{\sigma^2} \quad = \quad \dfrac{\purple{roundTo( 2, sum( SQR_DEV ) )}}{\green{DATA_POINTS}} \quad = \quad \red{VARIANCE_POP\text{ plural( "year", VARIANCE_POP )}^2} As you might guess from the notation, the population standard deviation (\pink{\sigma}) is found by taking the square root of the population variance (\red{\sigma^2}). \pink{\sigma} = \sqrt{\red{\sigma^2}} \pink{\sigma} = \sqrt{\red{VARIANCE_POP\text{ plural( "year", VARIANCE_POP )}^2}} = \pink{STDDEV_POP\text{ plural( "year", STDDEV_POP )}} The average animal( 1 ) at the zoo is MEAN year old.The average animal( 1 ) at the zoo is MEAN years old. There is a standard deviation of STDDEV_POP year.There is a standard deviation of STDDEV_POP years. You have found the following ages (in years) of DATA_POINTS animal(1). You have found the following ages (in years) of DATA_POINTS plural_form(animal(1), DATA_POINTS). Those plural_form(animal(1)) were randomly selected from the POPULATION animal(1) at your local zoo: Those plural_form(animal(1)) were randomly selected from the POPULATION plural_form(animal(1), POPULATION) at your local zoo: \qquadDATA.join(",\\enspace ") Based on your sample, what is the average age of the plural_form(animal( 1 ))? What is the standard deviation? Round your answers to the nearest tenth. Average age: \quad mean( DATA ) years old Standard deviation: \quad stdDev( DATA ) years Because we only have data for a small sample of the POPULATION animal( 1 ), we are only able to estimate the population mean and standard deviation by finding the sample mean (\blue{\overline{x}}) and sample standard deviation (\pink{s}). Because we only have data for a small sample of the POPULATION plural_form(animal( 1 ), POPULATION), we are only able to estimate the population mean and standard deviation by finding the sample mean (\blue{\overline{x}}) and sample standard deviation (\pink{s}). To find the sample mean, add up the values of all DATA_POINTS samples and divide by DATA_POINTS. \blue{\overline{x}} \quad = \quad \dfrac{\sum\limits_{i=1}^{\green{n}} x_i}{\green{n}} \quad = \quad \dfrac{\sum\limits_{i=1}^{\green{DATA_POINTS}} x_i}{\green{DATA_POINTS}} \blue{\overline{x}} \quad = \quad \dfrac{plus.apply( KhanUtil, DATA )}{\green{DATA_POINTS}} \quad = \quad \blue{MEAN\text{ YEARS_OLD}} Find the squared deviations from the mean for each sample. Since we don't know the population mean, estimate the mean by using the sample mean we just calculated (\blue{\overline{x}} = \blue{MEAN\text{ YEAR_TEXT}}). Find the squared deviations from the mean for each sample. Since we don't know the population mean, estimate the mean by using the sample mean we just calculated (\blue{\overline{x}} = \blue{MEAN\text{ YEARS_TEXT}}). Age x_i Distance from the mean (x_i - \blue{\overline{x}}) (x_i - \blue{\overline{x}})^2 POINT plural( "year", POINT ) roundTo( 2, POINT - MEAN ) plural( "year", roundTo( 2, POINT - MEAN ) ) SQR_DEV[ i ] plural( "year", SQR_DEV[ i ] )^2 Normally we can find the variance (\red{s^2}) by averaging the squared deviations from the mean. But remember we don't know the real population mean—we had to estimate it by using the sample mean. The age of any particular animal( 1 ) in our sample is likely to be closer to the average age of the DATA_POINTS animal( 1 ) we sampled. The age of any particular animal( 1 ) in our sample is likely to be closer to the average age of the DATA_POINTS plural_form(animal( 1 ), DATA_POINTS) we sampled. This is compared to the average age of all POPULATION animal( 1 ) in the zoo. This is compared to the average age of all POPULATION plural_form(animal( 1 ), POPULATION) in the zoo. Because of that, the squared deviations from the mean we calculated will probably underestimate the actual deviations from the population mean. To compensate for this underestimation, rather than simply averaging the squared deviations from the mean, we total them and divide by n - 1. \red{s^2} \quad = \quad \dfrac{\sum\limits_{i=1}^{\green{n}} (x_i - \blue{\overline{x}})^2}{\green{n - 1}} \red{s^2} \quad = \quad \dfrac{plus.apply( KhanUtil,$.map( SQR_DEV, function( x ) { return "\\color{purple}{" + x + "}"; }) )} {\green{DATA_POINTS - 1}}

\red{s^2} \quad = \quad \dfrac{\purple{roundTo(2, sum( SQR_DEV))}}{\green{DATA_POINTS - 1}} \quad = \quad \red{VARIANCE\text{ plural("year", VARIANCE)}^2}

The sample standard deviation (\pink{s}) is found by taking the square root of the sample variance (\red{s^2}).

\pink{s} = \sqrt{\red{s^2}}

\pink{s} = \sqrt{\red{VARIANCE\text{ plural("year", VARIANCE)}^2}} = \pink{STDDEV\text{ plural("year", STDDEV)}}

We can estimate that the average animal( 1 ) at the zoo is MEAN year old. We can estimate that the average animal( 1 ) at the zoo is MEAN years old. There is also a standard deviation of STDDEV year. There is also a standard deviation of STDDEV years.