def compute_gradient_LS(y, tx, w):
    """
    compute the gradient of least squares model.

    Input: 
        - y     = the label
        - tx    = the samples
        - w     = the weights for LS model

    Output:
        - gradient = the gradient for given (y,tx,w)
    """
    e = y - tx.dot(w)
    n_sample = y.shape[0]
    gradient = -1/n_sample*tx.T.dot(e)   
    return gradient