Linear regression with basis functions


In [1]:
import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline

In [2]:
def gen_data():
    """Generate data from a sine wave"""
    x = np.arange(0, 6.5, 0.5)
    x += np.random.rand(len(x))-0.5
    y = np.sin(x)
    return x,y

In [3]:
x,y = gen_data()
plt.plot(x, y, 'bo', markerfacecolor='white')
plt.savefig('sine.pdf', dpi=600)



In [ ]: