Example #1
0
def almlsqjac(params, *X):
    try:
        reload(cvalsim)
    except Exception:
        # import cvalsim
        from cvalsim import f as sim
    import numpy as np

    xdata, zdata = X[0]
    rp = np.ones(len(params))
    for i in range(len(params)):
        dparams = [0.0 for x in range(len(params))]
        dparams[i] = 1.0
        rp[i] = sum(-2.0 * (zdata - sim(xdata, params)) * sim(xdata, dparams))
    return rp
Example #2
0
def almlsq(params, *X):
    # return lsq objective
    # import numpy as np
    try:
        reload(cvalsim)
    except Exception:
        # import cvalsim
        from cvalsim import f as sim

    xdata, zdata = X[0]
    return sum((zdata - sim(xdata, params))**2)
Example #3
0
def almfeatmat(X, nparams):
    import numpy as np
    try:
        reload(cvalsim)
    except Exception:
        # import cvalsim
        from cvalsim import f as sim

    dims = np.shape(X)
    fm = np.ones([dims[0], nparams])
    dparams = [0.0 for x in range(nparams)]
    for i in range(nparams):
        dparams[i] = 1.0
        fm[:, i] = sim(X, dparams)
        dparams[i] = 0.0
    return fm