def _generate_sample_from_state(self, state, random_state=None):
if random_state is None:
random_state = self.random_state
random_state = check_random_state(random_state)
cur_means = self.means_[state]
cur_covs = self.covars_[state]
cur_weights = self.weights_[state]
i_gauss = random_state.choice(self.n_mix, p=cur_weights)
mean = cur_means[i_gauss]
if self.covariance_type == 'tied':
cov = cur_covs
else:
cov = cur_covs[i_gauss]
return sample_gaussian(mean, cov, self.covariance_type,
random_state=random_state)
评论列表
文章目录