Exemplo n.º 1
0
def c0_all(trajs):
    nfeatures = get_nfeatures(trajs)
    numer = np.zeros((nfeatures, nfeatures))
    denom = 0.0
    for traj in trajs:
        numer += traj.T @ traj
        denom += len(traj)
    return numer / denom
Exemplo n.º 2
0
def c0_trunc(trajs, cutlag):
    nfeatures = get_nfeatures(trajs)
    numer = np.zeros((nfeatures, nfeatures))
    denom = 0.0
    for traj in trajs:
        x = traj[: len(traj) - cutlag]
        numer += x.T @ x
        denom += len(x)
    return numer / denom
Exemplo n.º 3
0
def c0_rt(trajs, cutlag, weights):
    nfeatures = get_nfeatures(trajs)
    numer = np.zeros((nfeatures, nfeatures))
    denom = 0.0
    for traj, weight in zip(trajs, weights):
        x = traj[: len(traj) - cutlag]
        w = weight[: len(traj) - cutlag]
        numer += np.einsum("n,ni,nj", w, x, x)
        denom += np.sum(w)
    return numer / denom
Exemplo n.º 4
0
def c0_all_adj_ct(trajs, lag):
    nfeatures = get_nfeatures(trajs)
    numer = np.zeros((nfeatures, nfeatures))
    denom = 0.0
    for traj in trajs:
        x = traj[: len(traj) - lag]
        y = traj[lag:]
        numer += x.T @ x + y.T @ y
        denom += 2 * len(x)
    return numer / denom
Exemplo n.º 5
0
def ct_ra(trajs, lag, cutlag, weights):
    nfeatures = get_nfeatures(trajs)
    numer = np.zeros((nfeatures, nfeatures))
    denom = 0.0
    for traj, weight in zip(trajs, weights):
        w = weight[: len(traj) - cutlag]
        for shift in range(cutlag - lag + 1):
            x = traj[shift : shift + len(traj) - cutlag]
            y = traj[shift + lag : shift + len(traj) - cutlag + lag]
            numer += np.einsum("n,ni,nj", w, x, y)
            denom += np.sum(w)
    return numer / denom
Exemplo n.º 6
0
def ic_trunc(trajs, lags, cutlag):
    nfeatures = get_nfeatures(trajs)
    ic = np.zeros((nfeatures, nfeatures))
    for lag in lags:
        ic += ct_trunc(trajs, lag, cutlag)
    return ic
Exemplo n.º 7
0
def c0_all_adj_ic(trajs, lags):
    nfeatures = get_nfeatures(trajs)
    c0 = np.zeros((nfeatures, nfeatures))
    for lag in lags:
        c0 += c0_all_adj_ct(trajs, lag)
    return c0 / len(lags)
Exemplo n.º 8
0
def ic_all(trajs, lags):
    nfeatures = get_nfeatures(trajs)
    ic = np.zeros((nfeatures, nfeatures))
    for lag in lags:
        ic += ct_all(trajs, lag)
    return ic
Exemplo n.º 9
0
def c0_ra_adj_ic(trajs, lags, cutlag, weights):
    nfeatures = get_nfeatures(trajs)
    c0 = np.zeros((nfeatures, nfeatures))
    for lag in lags:
        c0 += c0_ra_adj_ct(trajs, lags, cutlag, weights)
    return c0 / len(lags)
Exemplo n.º 10
0
def ic_ra(trajs, lags, cutlag, weights):
    nfeatures = get_nfeatures(trajs)
    ic = np.zeros((nfeatures, nfeatures))
    for lag in lags:
        ic += ct_ra(trajs, lag, cutlag, weights)
    return ic