def compute_feature_derivative(errors, feature, coefficient, l2_penalty, feature_is_constant):
    """
    Purpose: Compute derivative of a feature wrt coefficient
    Input  : Error between true output and predicted output values, feature,
             coefficient, L2 penalty strength, if the feature is constant or not
    Output : Derivative of the feature wrt coefficient
    """
    if not feature_is_constant:
       derivative = feature.T.dot(errors)
    else:
       derivative = feature.T.dot(errors) - 2.0 * l2_penalty * coefficient
    return derivative