# \donttest{
# Example phoneme.R (simplified) from https://doi.org/10.1111/sjos.12692.
data(phoneme)
# resampling the log-periodograms
# 15 sample covariances for each phoneme
set.seed(12345)
nsubsamples <- 15
n <- 40
gg <- unique(Phoneme)
nphonemes <- length(gg)
N <- n*nsubsamples*nphonemes
M <- NCOL(logPeriodogram)
X <- matrix(NA, N, M)
gr <- integer(N)
r <- 1
first <- 1
last <- n
for (l in gg) {
for (i in 1:nsubsamples) {
X[first:last, ] <- logPeriodogram[sample(which(Phoneme==l),n), ]
gr[first:last] <- r
r <- r+1
first <- first+n
last <- last+n
}
}
# soft clustering
a <- wassersteinCluster(X, gr)
# how many cluster?
trimmedAverageSilhouette(a)
# the membership weigths show that the
# algorithm reconstructed the five phoneme
w <- ts(a[[4]]$w)
colnames(w) <- paste("Cluster", 1:5)
plot(w, xlab="Sample covariances", main="")
# }
Run the code above in your browser using DataLab