
Bayesian Gaussian mixture with variational inference (VBGMM)
Source:R/geron_w4d_native.R
morie_geron_variational_bayes_gmm.RdMean-field VB with Dirichlet(alpha0) prior on mixing weights;
responsibility uses E[log pi_k] = psi(alpha_k) - psi(sum alpha) via
morie_geron_digamma, which prunes unneeded components as
alpha0 -> 0.
Usage
morie_geron_variational_bayes_gmm(
X,
n_components = 3,
max_iter = 100,
alpha0 = 0.01,
tol = 1e-06,
var_floor = 1e-06,
seed = 0
)Value
list with weights, means, variances, resp, labels, alpha, n_effective, n_iter, estimate, n, method.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_variational_bayes_gmm(V)
#> $weights
#> [1] 0.1256918 0.7486163 0.1256918
#>
#> $means
#> [,1]
#> [1,] 1.0
#> [2,] 4.5
#> [3,] 8.0
#>
#> $variances
#> [,1]
#> [1,] 0.000001
#> [2,] 2.918827
#> [3,] 0.000001
#>
#> $resp
#> [,1] [,2] [,3]
#> [1,] 0.9993055 0.0006945169 0.0000000
#> [2,] 0.0000000 1.0000000000 0.0000000
#> [3,] 0.0000000 1.0000000000 0.0000000
#> [4,] 0.0000000 1.0000000000 0.0000000
#> [5,] 0.0000000 1.0000000000 0.0000000
#> [6,] 0.0000000 1.0000000000 0.0000000
#> [7,] 0.0000000 1.0000000000 0.0000000
#> [8,] 0.0000000 0.0006945169 0.9993055
#>
#> $labels
#> [1] 0 1 1 1 1 1 1 2
#>
#> $alpha
#> [1] 1.009305 6.011389 1.009305
#>
#> $n_effective
#> [1] 3
#>
#> $n_iter
#> [1] 35
#>
#> $estimate
#> [1] 3
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "Mean-field VB with a Dirichlet prior on the weights (E[log pi] via digamma) and MAP diagonal Gaussians"
#>