neuroprob/base.py
def mc_gen(self, q_mu, q_var, samples, neuron):
        """
        Function for generating Gaussian MC samples. No MC samples are drawn when the variance is 0.
        
        :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 samples: number of MC samples
        :returns: the samples
        :rtype: torch.tensor
        """
        q_mu = q_mu[:, neuron, :]
        if isinstance(q_var, Number): # zero scalar
            h = q_mu[None, ...].expand(samples, *q_mu.shape).reshape(-1, *q_mu.shape[1:]) if samples > 1 else q_mu
            
        elif len(q_var.shape) == 3:
            q_var = q_var[:, neuron, :]
            if samples == 1: # no expanding
                h = distributions.Rn_Normal(q_mu, q_var.sqrt())()
            else: # shape is (ll_samplesxcov_samples, neurons, time)
                h = distributions.Rn_Normal(q_mu, q_var.sqrt())((samples,)).view(-1, *q_mu.shape[1:])
                
        else: # full covariance
            q_var = q_var[:, neuron, ...]
            q_var.view(*q_var.shape[:2], -1)[:, :, ::q_var.shape[-1]+1] += self.jitter
            h = distributions.Rn_MVN(q_mu, covariance_matrix=q_var)((samples,)).view(-1, *q_mu.shape[1:])
            
        return h

        Function for generating Gaussian MC samples. No MC samples are drawn when the variance is 0.
        
        :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 samples: number of MC samples
        :returns: the samples
        :rtype: torch.tensor
        
Function for generating Gaussian MC samples. No MC samples are drawn when the variance is 0.
Function for generating Gaussian MC samples . No MC samples are drawn when the variance is 0 .
def mc_gen(self, q_mu, q_var, samples, neuron):
        q_mu = q_mu[:, neuron, :]
        if isinstance(q_var, Number): 
            h = q_mu[None, ...].expand(samples, *q_mu.shape).reshape(-1, *q_mu.shape[1:]) if samples > 1 else q_mu
        elif len(q_var.shape) == 3:
            q_var = q_var[:, neuron, :]
            if samples == 1: 
                h = distributions.Rn_Normal(q_mu, q_var.sqrt())()
            else: 
                h = distributions.Rn_Normal(q_mu, q_var.sqrt())((samples,)).view(-1, *q_mu.shape[1:])
        else: 
            q_var = q_var[:, neuron, ...]
            q_var.view(*q_var.shape[:2], -1)[:, :, ::q_var.shape[-1]+1] += self.jitter
            h = distributions.Rn_MVN(q_mu, covariance_matrix=q_var)((samples,)).view(-1, *q_mu.shape[1:])
        return h
def mc_gen ( self , q_mu , q_var , samples , neuron ) : q_mu = q_mu [ : , neuron , : ] if isinstance ( q_var , Number ) : h = q_mu [ None , ... ] . expand ( samples , * q_mu . shape ) . reshape ( - 1 , * q_mu . shape [ 1 : ] ) if samples > 1 else q_mu elif len ( q_var . shape ) == 3 : q_var = q_var [ : , neuron , : ] if samples == 1 : h = distributions . Rn_Normal ( q_mu , q_var . sqrt ( ) ) ( ) else : h = distributions . Rn_Normal ( q_mu , q_var . sqrt ( ) ) ( ( samples , ) ) . view ( - 1 , * q_mu . shape [ 1 : ] ) else : q_var = q_var [ : , neuron , ... ] q_var . view ( * q_var . shape [ : 2 ] , - 1 ) [ : , : , : : q_var . shape [ - 1 ] + 1 ] += self . jitter h = distributions . Rn_MVN ( q_mu , covariance_matrix = q_var ) ( ( samples , ) ) . view ( - 1 , * q_mu . shape [ 1 : ] ) return h
Function for generating Gaussian MC samples.
Function for generating Gaussian MC samples .
"""
        Function for generating Gaussian MC samples. No MC samples are drawn when the variance is 0.
        
        :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 samples: number of MC samples
        :returns: the samples
        :rtype: torch.tensor
        """ # zero scalar # no expanding # shape is (ll_samplesxcov_samples, neurons, time) # full covariance
None
torch.tensor
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
samples
number of MC samples
number of MC samples
neuron