K = 30
with pm.Model() as model:
    alpha = pm.Gamma('alpha', 1.0, 1.0)
beta = pm.Beta('beta', 1.0, alpha, shape=K)
w = pm.Deterministic('w', beta * T.concatenate([[1], T.extra_ops.cumprod(1 -
    beta)[:-1]]))
tau = pm.Gamma('tau', 1.0, 1.0, shape=K)
lambda_ = pm.Uniform('lambda', 0, 5, shape=K)
mu = pm.Normal('mu', 0, tau=lambda_ * tau, shape=K)
obs = pm.NormalMixture('obs', w, mu, tau=lambda_ * tau, observed=x_std)
with model:
    trace = pm.sample(2000, n_init=100000)
fig, ax = plt.subplots(figsize=(8, 6))
ax.bar(np.arange(K) - 0.4, trace['w'].mean(axis=0))
Как извлечь неконтролируемые кластеры из процесса Дирихле в PyMC3?