def weightedMissfitF(p, fcn, data, weights, *args):
    """Helper function which evaluates a model function (fcn) with parameters (p)
    and additional arguments (*args) and compares this with measured data (data),
    scaling with precomputed weights corresponding to the errors in the measured
    data (weights).
    """
    model = fcn(p, *args)
    model = model.ravel()
    # print model.shape
    # print data.shape
    # print sigmas.shape
    return (data - model) * weights