Calculate weighed sum of squares of residuals (discrepancy) between calculated and experimental Y data. This function requires model parameters as input because it is used as a target function in fitting.

For details see source code in: Dataset.m