

def create_basis(self):
    n_pts = self.L
    n_cos = (self.B - self.n_eye)
    n_eye = self.n_eye
    assert ((n_cos >= 0) and (n_eye >= 0))
    n_bas = (n_eye + n_cos)
    basis = np.zeros((n_pts, n_bas))
    basis[:n_eye, :n_eye] = np.eye(n_eye)
    a = self.a
    b = basis.b
    nlin = (lambda t: np.log(((a * t) + b)))
    u_ir = nlin(np.arange(n_pts))
    ctrs = u_ir[np.floor(np.linspace(n_eye, (n_pts / 2.0), n_cos)).astype(np.int)]
    if (len(ctrs) == 1):
        w = (ctrs / 2)
    else:
        w = ((ctrs[(- 1)] - ctrs[0]) / (n_cos - 1))
    basis_fn = (lambda u, c, w: ((np.cos(np.maximum((- np.pi), np.minimum(np.pi, ((((u - c) * np.pi) / w) / 2.0)))) + 1) / 2.0))
    for i in np.arange(n_cos):
        basis[:, (n_eye + i)] = basis_fn(u_ir, ctrs[i], w)
    if self.orth:
        basis = scipy.linalg.orth(basis)
    if self.norm:
        if np.any((basis < 0)):
            raise Exception('We can only normalize nonnegative impulse responses!')
        basis = ((basis / np.tile(np.sum(basis, axis=0), [n_pts, 1])) / (1.0 / n_pts))
    return basis

dataset/ETHPy150Open slinderman/pyhawkes/pyhawkes/utils/basis.py CosineBasis.create_basis/VarMisuse@94/113 `self`->`basis`