import math


def squared_loss(y, y_hat):
    """
    squared loss function
    :param y: :type numpy vector: label
    :param y_hat: :type numpy vector: observation
    :return: :type float: loss
    """
    loss = 0
    for i in range(len(y)):
        loss += math.pow(sum(y[i] - y_hat[i]), 2)/2
    return float(loss)