function error = lsq_sigmoid_error(parameter, x, y) % p(1) the amplitude % p(2) the slope % p(3) the x-shift % p(4) the y-shift y_est = parameter(1)./(1+ exp(-parameter(2) .* (x - parameter(3)))) + parameter(4); error = mean((y_est - y).^2);