neuroprob/base.py
def gh_gen(self, q_mu, q_var, points, neuron):
        """
        Computes the Gauss-Hermite quadrature locations and weights.
        
        :param torch.tensor q_mu: the mean of the MC distribution
        :param torch.tensor q_var: the (co)variance, type (univariate, multivariate) deduced 
                                   from tensor shape
        :param int points: number of quadrature points
        :returns: tuple of locations and weights tensors
        :rtype: tuple
        """
        locs, ws = np.polynomial.hermite.hermgauss(points) # sample points and weights for quadrature
        locs = torch.tensor(locs, dtype=self.tensor_type).repeat_interleave(q_mu.shape[0], 0).to(self.tbin.device)
        ws = torch.tensor(1 / np.sqrt(np.pi) * ws / q_mu.shape[0], # q_mu shape 0 is cov_samplesxtrials
                          dtype=self.tensor_type).repeat_interleave(q_mu.shape[0], 0).to(self.tbin.device)
        
        q_mu = q_mu[:, neuron, :].repeat(points, 1, 1) # fill sample dimension with GH quadrature points
        if isinstance(q_var, Number) is False:
            if len(q_mu.shape) > 3: # turn into diagonal
                q_var = q_var.view(*q_var.shape[:2], -1)[:, :, ::q_var.shape[-1]+1]
            q_var = q_var[:, neuron, :].repeat(points, 1, 1)
            h = torch.sqrt(2.*q_var) * locs[:, None, None] + q_mu
            
        else:
            h = q_mu
            
        return h, ws

        Computes the Gauss-Hermite quadrature locations and weights.
        
        :param torch.tensor q_mu: the mean of the MC distribution
        :param torch.tensor q_var: the (co)variance, type (univariate, multivariate) deduced 
                                   from tensor shape
        :param int points: number of quadrature points
        :returns: tuple of locations and weights tensors
        :rtype: tuple
        
Computes the Gauss-Hermite quadrature locations and weights.
Computes the Gauss - Hermite quadrature locations and weights .
def gh_gen(self, q_mu, q_var, points, neuron):
        locs, ws = np.polynomial.hermite.hermgauss(points) 
        locs = torch.tensor(locs, dtype=self.tensor_type).repeat_interleave(q_mu.shape[0], 0).to(self.tbin.device)
        ws = torch.tensor(1 / np.sqrt(np.pi) * ws / q_mu.shape[0], 
                          dtype=self.tensor_type).repeat_interleave(q_mu.shape[0], 0).to(self.tbin.device)
        q_mu = q_mu[:, neuron, :].repeat(points, 1, 1) 
        if isinstance(q_var, Number) is False:
            if len(q_mu.shape) > 3: 
                q_var = q_var.view(*q_var.shape[:2], -1)[:, :, ::q_var.shape[-1]+1]
            q_var = q_var[:, neuron, :].repeat(points, 1, 1)
            h = torch.sqrt(2.*q_var) * locs[:, None, None] + q_mu
        else:
            h = q_mu
        return h, ws
def gh_gen ( self , q_mu , q_var , points , neuron ) : locs , ws = np . polynomial . hermite . hermgauss ( points ) locs = torch . tensor ( locs , dtype = self . tensor_type ) . repeat_interleave ( q_mu . shape [ 0 ] , 0 ) . to ( self . tbin . device ) ws = torch . tensor ( 1 / np . sqrt ( np . pi ) * ws / q_mu . shape [ 0 ] , dtype = self . tensor_type ) . repeat_interleave ( q_mu . shape [ 0 ] , 0 ) . to ( self . tbin . device ) q_mu = q_mu [ : , neuron , : ] . repeat ( points , 1 , 1 ) if isinstance ( q_var , Number ) is False : if len ( q_mu . shape ) > 3 : q_var = q_var . view ( * q_var . shape [ : 2 ] , - 1 ) [ : , : , : : q_var . shape [ - 1 ] + 1 ] q_var = q_var [ : , neuron , : ] . repeat ( points , 1 , 1 ) h = torch . sqrt ( 2. * q_var ) * locs [ : , None , None ] + q_mu else : h = q_mu return h , ws
Computes the Gauss-Hermite quadrature locations and weights.
Computes the Gauss - Hermite quadrature locations and weights .
"""
        Computes the Gauss-Hermite quadrature locations and weights.
        
        :param torch.tensor q_mu: the mean of the MC distribution
        :param torch.tensor q_var: the (co)variance, type (univariate, multivariate) deduced 
                                   from tensor shape
        :param int points: number of quadrature points
        :returns: tuple of locations and weights tensors
        :rtype: tuple
        """ # sample points and weights for quadrature # q_mu shape 0 is cov_samplesxtrials # fill sample dimension with GH quadrature points # turn into diagonal
tuple of locations and weights tensors
tuple of locations and weights tensors
tuple
self
q_mu
the mean of the MC distribution
the mean of the MC distribution
q_var
the (co)variance, type (univariate, multivariate) deduced
from tensor shape
the ( co ) variance type ( univariate multivariate ) deduced from tensor shape
points
number of quadrature points
number of quadrature points
neuron