Running examples in ‘GMKMcharlie-Ex.R’ failed
The error most likely occurred in:

> ### Name: GM
> ### Title: Multithreaded Gaussian mixture trainer
> ### Aliases: GM
> 
> ### ** Examples
> 
> # =============================================================================
> # Examples below use 1 thread to pass CRAN check. Speed advantage of multiple
> # threads will be more pronounced for larger data.
> # =============================================================================
> 
> 
> # =============================================================================
> # Parameterize the iris data. Let the function initialize Gaussian kernels.
> # =============================================================================
> X = t(iris[1:4])
> # CRAN check only allows 2 threads at most. Increase `maxCore` for
> # acceleration.
> gmmRst = GMKMcharlie::GM(X, G = 4L, maxCore = 1L, friendlyOutput = FALSE)
Number of events reassigned: 108, 7, 9, 12, 5, 5, 1, 0, 
iteration = 1, log-likelihood = -202.724, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 2, log-likelihood = -182.256, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 3, log-likelihood = -178.47, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 4, log-likelihood = -176.476, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 5, log-likelihood = -174.961, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 6, log-likelihood = -173.558, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 7, log-likelihood = -172.172, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 8, log-likelihood = -170.902, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 9, log-likelihood = -169.785, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 10, log-likelihood = -168.797, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 11, log-likelihood = -167.965, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 12, log-likelihood = -167.245, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 13, log-likelihood = -166.479, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 14, log-likelihood = -165.743, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 15, log-likelihood = -165.34, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 16, log-likelihood = -165.165, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 17, log-likelihood = -165.078, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 18, log-likelihood = -165.025, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 19, log-likelihood = -164.985, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 20, log-likelihood = -164.954, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 21, log-likelihood = -164.928, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 22, log-likelihood = -164.907, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 23, log-likelihood = -164.888, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 24, log-likelihood = -164.871, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 25, log-likelihood = -164.856, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 26, log-likelihood = -164.842, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 27, log-likelihood = -164.828, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 28, log-likelihood = -164.814, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 29, log-likelihood = -164.8, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 30, log-likelihood = -164.785, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 31, log-likelihood = -164.768, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 32, log-likelihood = -164.751, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 33, log-likelihood = -164.734, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 34, log-likelihood = -164.719, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 35, log-likelihood = -164.707, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 36, log-likelihood = -164.7, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 37, log-likelihood = -164.696, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 38, log-likelihood = -164.694, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 39, log-likelihood = -164.693, each of the last 1 iterations yielded less than 0.001% increase in log-likelihood
iteration = 40, log-likelihood = -164.692, each of the last 2 iterations yielded less than 0.001% increase in log-likelihood
iteration = 41, log-likelihood = -164.692, each of the last 3 iterations yielded less than 0.001% increase in log-likelihood
iteration = 42, log-likelihood = -164.692, each of the last 4 iterations yielded less than 0.001% increase in log-likelihood
iteration = 43, log-likelihood = -164.692, each of the last 5 iterations yielded less than 0.001% increase in log-likelihood
iteration = 44, log-likelihood = -164.691, each of the last 6 iterations yielded less than 0.001% increase in log-likelihood
iteration = 45, log-likelihood = -164.691, each of the last 7 iterations yielded less than 0.001% increase in log-likelihood
iteration = 46, log-likelihood = -164.691, each of the last 8 iterations yielded less than 0.001% increase in log-likelihood
iteration = 47, log-likelihood = -164.691, each of the last 9 iterations yielded less than 0.001% increase in log-likelihood
> str(gmmRst)
List of 8
 $ alpha        : num [1:4] 0.2992 0.3675 0.0789 0.2545
 $ mu           : num [1:4, 1:4] 5.91 2.78 4.2 1.3 6.54 ...
 $ sigma        : num [1:16, 1:4] 0.2753 0.0969 0.1847 0.0544 0.0969 ...
 $ LogLikelihood: num -165
 $ AIC          : num 447
 $ BIC          : num 625
 $ fitted       : num [1:150] 7.32 3.97 6.71 4.35 6.84 ...
 $ clusterMember:List of 4
  ..$ : int [1:45] 51 52 53 54 55 56 57 58 59 60 ...
  ..$ : int [1:55] 69 71 73 78 84 101 102 103 104 105 ...
  ..$ : int [1:11] 6 15 16 17 22 24 27 32 37 44 ...
  ..$ : int [1:39] 1 2 3 4 5 7 8 9 10 11 ...
> 
> 
> 
> 
> # =============================================================================
> # Parameterize the iris data given Gaussian kernels.
> # =============================================================================
> G = 3L
> d = nrow(X) # Dimensionality.
> alpha = rep(1, G) / G
> mu = X[, sample(ncol(X), G)] # Sample observations as initial means.
> # Take the average variance and create initial covariance matrices.
> meanVarOfEachDim = sum(diag(var(t(X)))) / d
> covar = diag(meanVarOfEachDim / G, d)
> covars = matrix(rep(as.numeric(covar), G), nrow = d * d)
> 
> 
> # Models are sensitive to initialization.
> gmmRst2 = GMKMcharlie::GM(
+   X, alpha = alpha, mu = mu, sigma = covars, maxCore = 1L,
+   friendlyOutput = FALSE)
iteration = 1, log-likelihood = -732.279, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 2, log-likelihood = -216.261, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 3, log-likelihood = -196.475, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 4, log-likelihood = -194.79, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 5, log-likelihood = -193.908, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 6, log-likelihood = -193.4, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 7, log-likelihood = -193.042, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 8, log-likelihood = -192.726, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 9, log-likelihood = -192.417, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 10, log-likelihood = -192.087, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 11, log-likelihood = -191.692, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 12, log-likelihood = -191.155, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 13, log-likelihood = -190.41, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 14, log-likelihood = -189.506, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 15, log-likelihood = -188.532, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 16, log-likelihood = -187.505, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 17, log-likelihood = -186.422, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 18, log-likelihood = -185.35, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 19, log-likelihood = -184.372, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 20, log-likelihood = -183.489, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 21, log-likelihood = -182.721, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 22, log-likelihood = -182.104, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 23, log-likelihood = -181.556, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 24, log-likelihood = -180.936, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 25, log-likelihood = -180.454, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 26, log-likelihood = -180.268, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 27, log-likelihood = -180.211, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 28, log-likelihood = -180.194, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 29, log-likelihood = -180.188, each of the last 0 iterations yielded less than 0.001% increase in log-likelihood
iteration = 30, log-likelihood = -180.186, each of the last 1 iterations yielded less than 0.001% increase in log-likelihood
iteration = 31, log-likelihood = -180.186, each of the last 2 iterations yielded less than 0.001% increase in log-likelihood
iteration = 32, log-likelihood = -180.186, each of the last 3 iterations yielded less than 0.001% increase in log-likelihood
iteration = 33, log-likelihood = -180.186, each of the last 4 iterations yielded less than 0.001% increase in log-likelihood
iteration = 34, log-likelihood = -180.185, each of the last 5 iterations yielded less than 0.001% increase in log-likelihood
iteration = 35, log-likelihood = -180.185, each of the last 6 iterations yielded less than 0.001% increase in log-likelihood
iteration = 36, log-likelihood = -180.185, each of the last 7 iterations yielded less than 0.001% increase in log-likelihood
iteration = 37, log-likelihood = -180.185, each of the last 8 iterations yielded less than 0.001% increase in log-likelihood
iteration = 38, log-likelihood = -180.185, each of the last 9 iterations yielded less than 0.001% increase in log-likelihood
> str(gmmRst2)
List of 8
 $ alpha        : num [1:3] 0.367 0.333 0.299
 $ mu           : num [1:4, 1:3] 6.54 2.95 5.48 1.98 5.01 ...
 $ sigma        : num [1:16, 1:3] 0.387 0.0922 0.3028 0.0616 0.0922 ...
 $ LogLikelihood: num -180
 $ AIC          : num 448
 $ BIC          : num 581
 $ fitted       : num [1:150] 4.81 2.09 3.14 2.53 4.1 ...
 $ clusterMember:List of 3
  ..$ : int [1:55] 69 71 73 78 84 101 102 103 104 105 ...
  ..$ : int [1:50] 1 2 3 4 5 6 7 8 9 10 ...
  ..$ : int [1:45] 51 52 53 54 55 56 57 58 59 60 ...
> 
> 
> 
> 
> # =============================================================================
> # For fun, fit Rosenbrock function with a Gaussian mixture.
> # =============================================================================
> set.seed(123)
> rosenbrock <- function(x, y) {(1 - x) ^ 2 + 100 * (y - x ^ 2) ^ 2}
> N = 2000L
> x = runif(N, -2, 2)
> y = runif(N, -1, 3)
> z = rosenbrock(x, y)
> 
> 
> X = rbind(x, y)
> Xw = z * (N / sum(z)) # Weights on observations should sum up to N.
> gmmFit = GMKMcharlie::GM(X, Xw = Xw, G = 5L, maxCore = 1L, verbose = FALSE,
+   friendlyOutput = FALSE)
> 
> 
> oldpar = par()$mfrow
> par(mfrow = c(1, 2))
> plot3D::points3D(x, y, z, pch = 20)
tcltk DLL is linked to '/opt/R/arm64/lib/libtk8.6.dylib'
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
  call: fun(libname, pkgname)
  error: Tcl/Tk libraries are missing: install the Tcl/Tk component from the R installer
Execution halted