Skip to content

Instantly share code, notes, and snippets.

View Dimanaux's full-sized avatar

Dmitry Barskov Dimanaux

View GitHub Profile
@Dimanaux
Dimanaux / least_squares.py
Created November 12, 2017 18:17 — forked from silgon/least_squares.py
Basic Least Squares Implementation with pseudo inverse
"""
Basic Least Squares Implementation with pseudo inverse
"""
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(0)
t = np.linspace(0, 3, 20) # horizontal axis
x = np.array([3, 0, 4]) # a,b,c of f(t)=a+b*t+c*t^2
f = lambda t, x: x[0]+x[1]*t+x[2]*t**2 # f(t)