<commit_before>.. Copyright (C)  Google, Runestone Interactive LLC
   This work is licensed under the Creative Commons Attribution-ShareAlike 4.0
   International License. To view a copy of this license, visit
   http://creativecommons.org/licenses/by-sa/4.0/.


.. _measures_of_spread:

Measures of Spread
==================

Measures of center are very useful for giving you a “best guess” at a variable.
But how useful are those guesses?

In this section, you will learn about **standard deviation** and **variance**.
These are the most common "measures of spread" statistics, since they indicate 
how spread out a dataset is. These statistics are also used to inform how
useful other statistics (such as the mean) are for making predictions.

Trying to guess the value of a variable that doesn’t change much is a lot easier 
than trying to guess the value of a variable that can change drastically. To 
take an extreme example, suppose there are two very different cities next to 
each other. In “Consistentville”, everyone has the same yearly salary of 
$50,000. In “Wonkytown” exactly half the people have a yearly salary of 
$100,000, and the other half are unemployed.


.. https://docs.google.com/presentation/d/11O5DHFz8OJn2cIiDnSHd0hfAmY1HDaFQKtGBd3HYCmQ/edit?usp=sharing

.. image:: figures/consistentville_and_wonkytown.png
   :align: center
   :alt: A visual for the salaries of those in Wonkytown and Consistentville. 


.. https://docs.google.com/presentation/d/11O5DHFz8OJn2cIiDnSHd0hfAmY1HDaFQKtGBd3HYCmQ/edit?usp=sharing

.. image:: figures/city_salary_visual.png
   :align: center
   :alt: A visual for the salaries of those in Wonkytown and Consistentville with example incomes. 


Above is an example dataset for 6 people in each of the towns and their 
salaries.

.. fillintheblank:: mean_salary_in_consistentville

   What is the mean salary in Consistentville? (Give your answer in dollars.)
   |blank|

   - :(\$|)50(,|)000: Correct
     :x: Incorrect


.. fillintheblank:: mean_salary_in_wonkytown

   What is the mean salary in Wonkytown? (Give your answer in dollars.) |blank|

   - :(\$|)50(,|)000: Correct
     :x: Incorrect


Since all residents of Consistentville make the same salary of $50,000, the mean
salary is simply $50,000. Now since exactly half the residents of Wonkytown make
$100,000 and the other half make $0, it should make some intuitive sense that
the mean salary in Wonkytown is also $50,000. So “on average,” residents of
Consistentville and Wonkytown make the same salary.


.. shortanswer:: random_resident_salary
<commit_msg>Update measures_of_spread.rst<commit_after>.. Copyright (C)  Google, Runestone Interactive LLC
   This work is licensed under the Creative Commons Attribution-ShareAlike 4.0
   International License. To view a copy of this license, visit
   http://creativecommons.org/licenses/by-sa/4.0/.


.. _measures_of_spread:

Measures of Spread
==================

Measures of center are very useful for giving you a “best guess” at a variable.
But how useful are those guesses?

In this section, you will learn about **standard deviation** and **variance**.
These are the most common "measures of spread" statistics, since they indicate 
how spread out a dataset is. These statistics are also used to inform how
useful other statistics (such as the mean) are for making predictions.

Trying to guess the value of a variable that doesn’t change much is a lot easier 
than trying to guess the value of a variable that can change drastically. To 
take an extreme example, suppose there are two very different cities next to 
each other. In “Consistentville”, everyone has the same yearly salary of 
$50,000. In “Wonkytown” exactly half the people have a yearly salary of 
$100,000, and the other half are unemployed.


.. https://docs.google.com/presentation/d/11O5DHFz8OJn2cIiDnSHd0hfAmY1HDaFQKtGBd3HYCmQ/edit?usp=sharing

.. image:: figures/consistentville_and_wonkytown.png
   :align: center
   :alt: A visual for the salaries of those in Wonkytown and Consistentville. 


Above is an example dataset for 6 people in each of the towns and their 
salaries.

.. fillintheblank:: mean_salary_in_consistentville

   What is the mean salary in Consistentville? (Give your answer in dollars.)
   |blank|

   - :(\$|)50(,|)000: Correct
     :x: Incorrect


.. fillintheblank:: mean_salary_in_wonkytown

   What is the mean salary in Wonkytown? (Give your answer in dollars.) |blank|

   - :(\$|)50(,|)000: Correct
     :x: Incorrect


Since all residents of Consistentville make the same salary of $50,000, the mean
salary is simply $50,000. Now since exactly half the residents of Wonkytown make
$100,000 and the other half make $0, it should make some intuitive sense that
the mean salary in Wonkytown is also $50,000. So “on average,” residents of
Consistentville and Wonkytown make the same salary.


.. shortanswer:: random_resident_salary

{'fraction_non_alphanumeric': 0.07639030352413934, 'fraction_numerical': 0.024444897127724588, 'mean_word_length': 4.245726495726496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4440903', 'n_tokens_mistral': 1587, 'n_tokens_neox': 1439, 'n_words': 635}