INNER CODE UNIT · Python
LSfit
mszell/geospatialdatascience · unit11_mobilityindividual/stats_utils.py:220
def LSfit(function, parameters, y, x):
"""
*** ATTENTION! ***
*** _x_ and _y_ MUST be NUMPY arrays !!! ***
*** and use NUMPY FUNCTIONS, e.g. np.exp() and not math.exp() ***
_function_ -> Used to calculate the sum of the squares:
min sum( (y - function(x, parameters))**2 )
{params}
_parameters_ -> List of elements of the Class "Parameter"
_y_ -> List of observations: [ y0, y1, ... ]
_x_ -> List of variables: [ [x0,z0], [x1,z1], ... ]
Then _function_ must be function of xi=x[0] and zi=x[1]:
def f(x): return x[0] * x[1] / mu()
# Gaussian