Lab: Useful Math

Functions we use all the time to manage data

For this lab, you're going to implement mean and standard_deviation functions. Yes, there are existing versions, but here you're going to make your own.

mean is the average over a list of numbers. Your function should take a list of numbers and return the average. You can use the built-in sum function here.

standard_deviation is a little more complicated (not that much). It also takes a list of numbers, and it returns a value indicating how closly those numbers group up around the mean. Read the page linked below to see how the standard deviation is calculated (the initial formula looks complicated, but you'll see from the explanation that it is not), then write a function to implement it. Your function should take a list of numbers and return the standard deviation.

Remember! For a non-trivial problem, start by figuring out what the data is, and what steps you need to implement.

https://www.mathsisfun.com/data/standard-deviation-formulas.html

Follow the conventions from the First Function lab:

  • Define your two functions, mean and standard_deviation, at the top of the code file.
  • Include docstrings.
  • Define a main function at the bottom.
  • Put the code to test your functions and show they work in main.
  • Call main() at the end of the file.
  • No other code statements besides the call to main() should be outside functions!