def log_likelihood(self,x, K_extra=<NUM_LIT:1>):
x = np.asarray(x)<EOL>ks = self._get_occupied()<EOL>K = len(ks)<EOL>K_total = K + K_extra<EOL>obs_distns = []<EOL>for k in range(K):<EOL><INDENT>o = copy.deepcopy(self.obs_distn)<EOL>o.resample(data=self._get_data_withlabel(k))<EOL>obs_distns.append(o)<EOL><DEDENT>for k in range(K_extra):<EOL><INDENT>o = copy.deepcopy(self.obs_distn)<EOL>o.resample()<EOL>obs_distns.append(o)<EOL><DEDENT>weights = Categorical(alpha_0=self.alpha_0,<EOL>K=K_total,<EOL>weights=None)<EOL>assert len(self.labels_list) == <NUM_LIT:1><EOL>weights.resample(data=self.labels_list[<NUM_LIT:0>].z)<EOL>vals = np.empty((x.shape[<NUM_LIT:0>],K_total))<EOL>for k in range(K_total):<EOL><INDENT>vals[:,k] = obs_distns[k].log_likelihood(x)<EOL><DEDENT>vals += weights.log_likelihood(np.arange(K_total))<EOL>assert not np.isnan(vals).any()<EOL>return logsumexp(vals,axis=<NUM_LIT:1>).sum()<EOL>
Estimate the log likelihood with samples from
 the model. Draw k_extra components which were not populated by
 the current model in order to create a truncated approximate
 mixture model.