neuroprob/likelihoods.py
def sample(self, rate, neuron=None, XZ=None):
        """
        Sample from the Gamma-Poisson mixture.
        
        :param numpy.array rate: input rate of shape (trials, neuron, timestep)
        :param int max_count: maximum number of spike counts per time bin
        :returns: spike train of shape (trials, neuron, timesteps)
        :rtype: np.array
        """
        neuron = self._validate_neuron(neuron)
        rate_ = rate[:, neuron, :]
        
        if self.dispersion_mapping is None:
            r_ = 1./(self.r_inv[None, :, None].expand(rate.shape[0], self.neurons, 
                                                      rate_.shape[-1]).data.cpu().numpy()
                     + 1e-6)[:, neuron, :]
        else:
            samples = rate.shape[0]
            disp = self.eval_dispersion_mapping(XZ, samples, neuron)[None, ...].expand(rate.shape[0], 
                                                                                       *rate_.shape[1:])
            r_ = 1./(disp.data.cpu().numpy() + 1e-6)
            
        s = np.random.gamma(r_, rate_*self.tbin.item()/r_)
        return torch.poisson(torch.tensor(s)).numpy()

        Sample from the Gamma-Poisson mixture.
        
        :param numpy.array rate: input rate of shape (trials, neuron, timestep)
        :param int max_count: maximum number of spike counts per time bin
        :returns: spike train of shape (trials, neuron, timesteps)
        :rtype: np.array
        
Sample from the Gamma-Poisson mixture.
Sample from the Gamma - Poisson mixture .
def sample(self, rate, neuron=None, XZ=None):
        neuron = self._validate_neuron(neuron)
        rate_ = rate[:, neuron, :]
        if self.dispersion_mapping is None:
            r_ = 1./(self.r_inv[None, :, None].expand(rate.shape[0], self.neurons, 
                                                      rate_.shape[-1]).data.cpu().numpy()
                     + 1e-6)[:, neuron, :]
        else:
            samples = rate.shape[0]
            disp = self.eval_dispersion_mapping(XZ, samples, neuron)[None, ...].expand(rate.shape[0], 
                                                                                       *rate_.shape[1:])
            r_ = 1./(disp.data.cpu().numpy() + 1e-6)
        s = np.random.gamma(r_, rate_*self.tbin.item()/r_)
        return torch.poisson(torch.tensor(s)).numpy()
def sample ( self , rate , neuron = None , XZ = None ) : neuron = self . _validate_neuron ( neuron ) rate_ = rate [ : , neuron , : ] if self . dispersion_mapping is None : r_ = 1. / ( self . r_inv [ None , : , None ] . expand ( rate . shape [ 0 ] , self . neurons , rate_ . shape [ - 1 ] ) . data . cpu ( ) . numpy ( ) + 1e-6 ) [ : , neuron , : ] else : samples = rate . shape [ 0 ] disp = self . eval_dispersion_mapping ( XZ , samples , neuron ) [ None , ... ] . expand ( rate . shape [ 0 ] , * rate_ . shape [ 1 : ] ) r_ = 1. / ( disp . data . cpu ( ) . numpy ( ) + 1e-6 ) s = np . random . gamma ( r_ , rate_ * self . tbin . item ( ) / r_ ) return torch . poisson ( torch . tensor ( s ) ) . numpy ( )
Sample from the Gamma-Poisson mixture.
Sample from the Gamma - Poisson mixture .
"""
        Sample from the Gamma-Poisson mixture.
        
        :param numpy.array rate: input rate of shape (trials, neuron, timestep)
        :param int max_count: maximum number of spike counts per time bin
        :returns: spike train of shape (trials, neuron, timesteps)
        :rtype: np.array
        """
spike train of shape (trials, neuron, timesteps)
spike train of shape ( trials neuron timesteps )
np.array
self
rate
input rate of shape (trials, neuron, timestep)
input rate of shape ( trials neuron timestep )
neuron
XZ
max_count
maximum number of spike counts per time bin
maximum number of spike counts per time bin