def create_basis(self):
        n_pts = self.L              # Number of points at which to evaluate the basis
        n_cos = self.B - self.n_eye # Number of cosine basis functions'
        n_eye = self.n_eye          # Number of identity basis functions
        assert n_cos >= 0 and n_eye >= 0

        n_bas = n_eye + n_cos
        basis = np.zeros((n_pts,n_bas))

        # The first n_eye basis elements are identity vectors in the first time bins
        basis[:n_eye,:n_eye] = np.eye(n_eye)

        # The remaining basis elements are raised cosine functions with peaks
        # logarithmically warped between [n_eye*dt:dt_max].

        a = self.a                          # Scaling in log time
        b = self.b                          # Offset in log time
        nlin = lambda t: np.log(a*t+b)      # Nonlinearity
        u_ir = nlin(np.arange(n_pts))       # Time in log time
        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)    # Width of the cosine tuning curves

        # Basis function is a raised cosine centered at c with width w
        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)


        # Orthonormalize basis (this may decrease the number of effective basis vectors)
        if self.orth:
            basis = scipy.linalg.orth(basis)
        if self.norm:
            # We can only normalize nonnegative bases
            if np.any(basis<0):
                raise Exception("We can only normalize nonnegative impulse responses!")

            # Normalize such that \int_0^1 b(t) dt = 1
            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/original