Week 1 - Introduction

Due January 18 at 8 PM

A quick introduction to git and python.

Please run through this tutorial on how git functions. Further reading on git exists here.

For an introduction to python programming, please follow the tutorials here and here.

We will cover certain aspects of python programming and specific packages throughout the course. However, at the end of these tutorials, you should be comfortable with the exercises below.


In [3]:
%matplotlib inline
import numpy as np
from sklearn.datasets import load_boston
import matplotlib.pyplot as plt

(1) Write a function that stores the first 100 numbers of the fibannaci sequence in a numpy array.

Then write two assertions as tests of your function.


In [12]:
def fib():
    arr = np.zeros(100, dtype=np.float64)
    
    arr[1] = 1
    
    for ii in range(2, 100):
        arr[ii] = arr[ii-1] + arr[ii-2]
    
    return arr

seq = fib()

assert(seq[99] == seq[98] + seq[97])
assert(seq[2] == 1)

(2) Plot the selected data from this Boston home price dataset, labeling the X and Y axes.


In [5]:
boston = load_boston()

y = boston.target
x = boston.data[:, 0]
ylabel = "Home Prices"
xlabel = "Crime"

plt.scatter(x, y);
plt.xlabel(xlabel);
plt.ylabel(ylabel);


(3) Write a function that satisfies the assertions below.


In [20]:
def func(A, B):
    return A + (2 * B)

assert(func(0, 20) == 40)
assert(func(1, 10) == 21)
assert(func(2, 5) == 12)
assert(func(3, 2) == 7)
assert(func(4, 1) == 6)

(4) Briefly describe one skill and/or ability you would like to take away from this class.

Answers.

(5) Describe your previous experience with programming, statistics, and modeling, including courses and which languages you've used. There is no wrong answer here—this will help us better tailor the class.

Answers.

(6) Commit these files to git with a descriptive message.