def VB_sample(self,gd,x=None): """ Sampling of the BGMM model on test points (the 'grid')in order to have an estimate of the posterior on these points Parameters ---------- gd = a grid descriptor, i.e. the grid on chich the BGMM is sampled x = None: used for plotting (empirical data) Returns ------- Li : array of shape (nbnodes,self.k), the posterior for each node and component """ if self.estimated: grid = gd.make_grid() Li = fc.bayesian_gmm_sampling(self.prior_means, \ self.prior_precisions, self.prior_shrinkage, self.prior_weights, self.prior_dof, self.means, self.precisions, self.shrinkage, self.weights, self.dof, grid) else: raise ValueError, "the model has not been estimated" if x!=None: self.show(x,gd,np.exp(Li)) return Li.sum(1)
def sample_on_data(self,grid): """ Sampling of the BGMM model on test points (the 'grid')in order to have an estimate of the posterior on these points Parameters ---------- grid: a set of points from which the posterior should be sampled Returns ------- Li : array of shape (nbnodes,self.k), the posterior for each node and component """ if self.estimated: Li = fc.bayesian_gmm_sampling( self.prior_means,\ self.prior_precisions, self.prior_shrinkage, self.prior_weights, self.prior_dof, self.means, self.precisions, self.shrinkage, self.weights, self.dof, grid) else: raise ValueError, "the model has not been estimated" return Li