Skip to content

Instantly share code, notes, and snippets.

@chyld
Last active June 10, 2020 18:58
Show Gist options
  • Save chyld/1595487bd5389007cbbdfa622ff3962c to your computer and use it in GitHub Desktop.
Save chyld/1595487bd5389007cbbdfa622ff3962c to your computer and use it in GitHub Desktop.

This is a Live Coding Problem

Problem Statement

  • Sally owns her own trucking company
  • Every time one of her drivers goes on job, they log how many miles they drove and how many gallons of gas were consumed
  • Here is a list of the miles driven per job
10.,  20.,  30.,  40.,  50.,  60.,  70.,  80.,  90., 100., 110.,
120., 130., 140., 150., 160., 170., 180., 190., 200., 210., 220.,
230., 240., 250., 260., 270., 280., 290., 300., 310., 320., 330.,
340., 350., 360., 370., 380., 390., 400., 410., 420., 430., 440.,
450., 460., 470., 480., 490., 500.
  • Here is a list of the amount of gas, in gallons, consumed during each job
5.1 ,  5.54,  5.09,  4.67,  2.13,  4.51,  6.47,  5.09, 10.19,
6.66,  9.42,  9.7 ,  5.39, 11.76, 18.21, 18.1 , 20.92, 15.83,
15.68, 10.28,  8.25, 10.81, 23.83, 16.74, 17.2 , 20.36, 23.85,
18.3 , 19.83, 22.38, 37.61, 26.34, 24.06, 24.46, 27.72, 26.9 ,
31.02, 32.53, 21.48, 34.3 , 28.74, 37.72, 31.9 , 33.35, 36.62,
27.78, 41.13, 38.7 , 34.89, 34.36
  • Sally's drivers have never exceeded 500 miles on a single job
  • However, she would like you to figure out how many gallons of gas would be consumed if a driver took a 750 mile trip
  • Gas is $3.45 per gallon
  • How much money would it cost one of Sally's drivers to drive 750 miles
  • What are the values for the Beta coefficients, and how would you explan them to a nontechnical person
  • Plot the independent and dependent data on a scatter plot
  • Draw a line of best fit through the data
  • What is the R-squared value, is it good

Skills required to solve

  • Basic Problem Solving
  • Linear Regression
  • Linear Algebra
  • Python
  • Numpy
  • Matplotlib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment