Example #1
0
    def __init__(self, Y, link, trLen, nLeg=50, nHerm=20, dtstep=0.001):
        super(PointProcess, self).__init__()
        """
        Class for PointProcess expected log likelihood
        Y       -- data list with [R][D][Nspikes] trials, neurons, number of spikes
        link    -- non-linearity module
        trLen   -- list with length of each trial
        nLeg    -- number of quadrature nodes to use for Gauss Legendre (to evaluate normalizer)
        nHerm   -- number of Gauss Hermite quadrature nodes to use for evaluating Gaussian expectations of link function (if not analytic)
        """

        self.nTrials = len(trLen)  # number of trials
        self.nOut = len(Y[0])  # number of output dimensions
        self.link = link  # link function object
        self.trLen = trLen  # length of each trial in units of time
        self.dtstep = dtstep  # discretisation for inference
        # Gauss Hermite quadrature nodes and weights
        xxH, wwH = gauss_hermite(nHerm)
        self.xxHerm = xxH
        self.wwHerm = wwH

        # Gauss Legendre quadrature nodes and weights
        xxL = torch.zeros(self.nTrials, nLeg).type(float_type)
        wwL = torch.zeros(self.nTrials, nLeg).type(float_type)

        for rr in range(self.nTrials):
            xxL[rr, :], wwL[rr, :] = gauss_legendre(nLeg, a=0, b=trLen[rr])

        self.xxLeg = xxL  # R x n
        self.wwLeg = wwL

        # arrange data and ensure everything is a pytorch variable
        self.arrange_data(Y)
Example #2
0
def gauss_hermite_design(N):
    """
    Tensor product Gauss-Hermite quadrature points.

    :param int[] N: Contains the number of points per dimension in the tensor
        product design.

    :return: design, N-by-m matrix that contains the design points.
    :rtyp: ndarray
    """
    Npts = int(np.prod(np.array(N)))
    logging.getLogger(__name__).debug('Gauss-Hermite design with {:d} points in {:d} dimensions.'.format(Npts, len(N)))
    design = gauss_hermite(N)[0]
    return design
Example #3
0
def gauss_hermite_design(N):
    """Tensor product Gauss-Hermite quadrature points.

    Parameters
    ----------
    N : int[]
        contains the number of points per dimension in the tensor product design

    Returns
    -------
    design : ndarray
        N-by-m matrix that contains the design points
    """
    design = gauss_hermite(N)[0]
    return design
Example #4
0
def unbounded_design(N):
    return gauss_hermite(N)[0]
Example #5
0
def gauss_hermite_design(N):
    return gauss_hermite(N)[0]