Generate a correct python program to perform linear regression.
import numpy as np

def linear_regression(X, y):
    X_b = np.array([np.ones(X.shape[0]), X]).T
    theta = np.linalg.inv(X_b.T @ X_b) @ X_b.T @ y
    return theta