Skip to content

Commit 554812f

Browse files
committed
updates
1 parent 900b883 commit 554812f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

R/00_pmclust_reduceK.r

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ pmclust.reduceK <- function(X = NULL, K = 2, MU = NULL,
88
stop("kmeans/pkmeans is not supported in reduceK.")
99
}
1010

11-
### Run through original pmclust().
11+
# Run through original pmclust().
1212
ret <- pmclust(X = X, K = K, MU = MU, algorithm = algorithm,
1313
RndEM.iter = RndEM.iter, CONTROL = CONTROL,
1414
method.own.X = method.own.X, rank.own.X = rank.own.X,
1515
comm = comm)
1616

17-
### Repeat if error occurs.
17+
# Repeat if error occurs.
1818
repeat{
1919
if(ret$check$convergence == 99 && K > 1){
20-
### Drop specific i.k if available or
21-
### drop the smallest class or
22-
### drop the class with the smallest eta among all small classes or
23-
### drop all classes with 0 elements.
20+
# Drop specific i.k if available or
21+
# drop the smallest class or
22+
# drop the class with the smallest eta among all small classes or
23+
# drop all classes with 0 elements.
2424
PARAM.new <- ret$param
2525
if(.pmclustEnv$CONTROL$stop.at.fail && .pmclustEnv$FAIL.i.k > 0){
2626
i.k <- .pmclustEnv$FAIL.i.k
@@ -32,7 +32,7 @@ pmclust.reduceK <- function(X = NULL, K = 2, MU = NULL,
3232
}
3333
K <- K - length(i.k)
3434

35-
### Initial global storage.
35+
# Initial global storage.
3636
if(algorithm[1] %in% .PMC.CT$algorithm.gbd){
3737
PARAM.org <- set.global(K = K)
3838
} else if(algorithm[1] %in% .PMC.CT$algorithm.dmat){
@@ -41,12 +41,13 @@ pmclust.reduceK <- function(X = NULL, K = 2, MU = NULL,
4141
comm.stop("The algorithm is not found.")
4242
}
4343

44-
### Replacing PARAM.org by previous PARAM.new.
44+
# Replacing PARAM.org by previous PARAM.new.
4545
PARAM.org$ETA <- PARAM.new$ETA[-i.k] / sum(PARAM.org$ETA[-i.k])
4646
PARAM.org$log.ETA <- log(PARAM.org$ETA)
4747
PARAM.org$MU <- matrix(PARAM.new$MU[, -i.k], ncol = K)
4848
PARAM.org$SIGMA <- PARAM.new$SIGMA[-i.k]
4949

50+
# Need one e-step to initial storage.
5051
if(algorithm[1] %in% .PMC.CT$algorithm.gbd){
5152
e.step.spmd(PARAM.org)
5253
} else if(algorithm[1] %in% .PMC.CT$algorithm.dmat){

0 commit comments

Comments
 (0)