Description Usage Arguments Examples
This function allows you to run a VI algorithm for learning Poisson mixtures
1 | VI_PMM_algo(x, K, iter = 1000, alpha = 0.1, a = 4.5, b = 0.25)
|
x |
this is the data |
K |
this is the number |
iter |
number of iterations defaults to 1000 |
alpha |
hyperparameter of probability distribution of Poisson models defaults to 0.1 |
a |
Gamma prior parameter defaults to 0.1 |
b |
Gamma prior parameter defaults to 0.25 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #generate some Poisson mixture data
data <- c(rpois(100,2), rpois(100,10))
#run the VI algorithm to learn the mixture model
t2 <- VI_PMM_algo(data,2,iter = 1000)
#plot the VI objective function, should be monotonically increasing and monitors convergence
plot(t2$L_vi,
type = 'l',
main = "convergence of VI objective function",
bty = 'n')
#check the cluster assignments (using original data this is not a prediction, which can also be done)
cluster_indicator <- c()
for(i in 1:length(data)){
cluster_indicator <- c(cluster_indicator,which.max(t2$norm_phi[i,]))
}
plot(data,cluster_indicator,
pch = 16,
bty = 'n')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.