You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think we should wait with this issue until the BNP PR is merged. I integrated CRP representations into the PR and learning an IMM with a CRP prior will be straightforward with the PR.
# Some data points.
data = [-2,2,-1.5,1.5]
# Parameters of the base distribution of the Dirichlet process.
mu_0 =mean(data)
sigma_0 =4# Hyper-parameter of the Dirichlet process, i.e. concentration parameter.
alpha =0.25@modelinfiniteMixtureModel(y, rpm) =begin# Definition of the base distribution.
H =Normal(mu_0, sigma_0)
# Latent assignments.
N =length(y)
z =tzeros(Int, N)
# Cluster counts.
cluster_counts =tzeros(Int, N)
# Cluster locations.
x =tzeros(Float64, N)
for i in1:N
# Draw assignments using a Chinese restaurant process.
z[i] ~ChineseRestaurantProcess(rpm, cluster_counts)
if cluster_counts[z[i]] ==0# Cluster is new, therefore, draw new location.
l ~ H
x[z[i]] ~ H
end
cluster_counts[z[i]] +=1# Draw observation.
y[i] ~Normal(x[z[i]], sigma_1)
endend# We use a Dirichlet process as the random probability measure.
rpm =DirichletProcess(alpha)
# Use a sequential Monte Carlo sampler.
sampler =SMC(5000)
# Inference.
mf =infiniteMixtureModel(data, rpm)
samples =sample(mf, sampler)
CRP Demo
The text was updated successfully, but these errors were encountered: