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.  The equations are from Harris-‘Quantitative Chemical Analysis’ (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 Montauk and KLGA data and determine the correlation.   Do not look at the answers until you are done today.  Talk to your neighbors about turning equations into code. Getting the thinking and parenthesis correct takes time.  Everything is here https://github.com/bmaillou/BigDataPython/tree/master/07-FitaLine

VIDEO

Make sure to take your quiz!

Homework 6

Homework 6 Due Monday February 17, 2025

  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.  Make sure to clearly state your 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!  The text box makes it look professional.