Class 07 – Fit a line

Overview

We are going to explore more how to do some math in iPython and how to make some plots.  Today you are going to write your own program to get the best fit line (pdf=FitALine).  The equations are from Harris-‘Quantitative Chemical Analysis’ (Harris-fit-a-line) (pdf=Harris-fit-a-line).  I am going to give you the equation and then using numpy you will make it work.  Once it is working you will then go back and get your your KNYC and KLGA data and determine the correlation.   Do not look at the answers until you are done ( Fit a line answer.  Don’t look until done!  pdf=Fit a line answers) today.  Talk to your neighbors about turning equations into code.

VIDEO

Make sure to take your quiz!

Homework 6

Homework 6 Due Wednesday February 14, 2024

Repeated from last class.

  1. Don’t Forget you are supposed to be working on SoloLearn.  Go back and make sure you started it correctly!

THIS IS THE REGULAR HOMEWORK FOR MONDAY!

  1. You need to go and create a dataset and then fit a line to it.
    1. You should present a hypothesis, get the data, determine the fit.
    2. Your data and hypothesis can be anything and does not need to be “real”.  you can be creative.  You could interview friends to get data points.  You can search online.  You can make it as fun as you want. You can make something up!  But you need to state a hypothesis.  Have fun with it.
    3. You need at least 5 data points that you generate from your ideas and hypotheses.  Make it look good!  This is not about the data.  This is about the idea of presenting a hypothesis and fitting a line!  make it fun!  Be goofy!
    4. Once you have the data make the graph look professional.  Then you have to write a figure caption and summary sentences about your results in markdown.  This should all be in one ipython notebook with nice Markdown.
      1. For this I mean add a markdown cell below each graph explaining the result in a figure caption.
    5. The results should be presented from both your method for fitting a line and a python method for fitting a line.  This is redundant but make sure to do it!  Fit the same data twice to make sure you get the same result. You should make sure that your line fitting algorithm and the python algorithm give the same answer.
      1. For your method I mean where you did the math on your own.
      2. For the python method I mean linregress.
    6. The results need to be presented in the figure as a title or a text box.  I like the text box!

3.  My grading fit-a-line