':key: LDAæš¡åäž­çGibbsæœæ ·è¿çš
:param is_calculate_preplexity: æ¯åŠè®¡ç®preplexityåŒ'

def gibbs_sampling(self, is_calculate_preplexity):

    pp_list = []
    pp_var = numpy.inf
    last_iter = (self.current_iter + 1)
    iters_num = (self.iters_num if (self.iters_num != 'auto') else MAX_ITER_NUM)
    for self.current_iter in range(last_iter, (last_iter + iters_num)):
        info = '......'
        if is_calculate_preplexity:
            pp = self.calculate_perplexity()
            pp_list.append(pp)
            pp_var = (numpy.var(pp_list[(- VAR_NUM):]) if (len(pp_list) >= VAR_NUM) else numpy.inf)
            info = ((',    preplexity:    ' + str(pp)) + ((',    var:    ' + str(pp_var)) if (len(pp_list) >= VAR_NUM) else ''))
        logging.debug(((' DCTB iteration    ' + str(self.current_iter)) + info))
        if ((self.iters_num == 'auto') and (pp_var < (VAR_NUM / 2))):
            break
        for m in range(self.M):
            for n in range(len(self.Z[m])):
                w = self.arts_Z[m][n]
                k = self.Z[m][n]
                self.nd[(m, k)] -= 1
                self.ndsum[(m, 0)] -= 1
                self.nw[(k, w)] -= 1
                self.nwsum[(k, 0)] -= 1
                if (self.prior_word and (w in self.prior_word)):
                    k = numpy.random.choice(self.prior_word[w])
                else:
                    theta_p = ((self.nd[m] + self.alpha) / (self.ndsum[(m, 0)] + self.sum_alpha))
                    if (self.local_2_global and self.train_model):
                        w_g = self.local_2_global[w]
                        phi_p = (((self.train_model.nw[:, w_g] + self.nw[:, w]) + self.beta[w_g]) / ((self.train_model.nwsum[:, 0] + self.nwsum[:, 0]) + self.sum_beta))
                    else:
                        phi_p = ((self.nw[:, w] + self.beta[w]) / (self.nwsum[:, 0] + self.sum_beta))
                    multi_p = (theta_p * phi_p)
                    k = LdaBase.multinomial_sample(multi_p)
                self.nd[(m, k)] += 1
                self.ndsum[(m, 0)] += 1
                self.nw[(k, w)] += 1
                self.nwsum[(k, 0)] += 1
                self.Z[m][n] = k
    return
