def fit_engine(g, x, y):
    """
    This function is to do fitting based on given x and y values.

    Parameters
    ----------
    g : array_like
        fitting object
    x : array
        independent variable
    y : array
        dependent variable

    Returns
    -------
    result : array_like
        object of fitting results
    y_fit : array
        fitted y
    """
    result = g.fit(y, x=x)
    y_fit = result.best_fit

    return result, y_fit