Rev 7920 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
R version 4.0.3 Patched (2021-01-18 r79850) -- "Bunny-Wunnies Freak Out"Copyright (C) 2021 The R Foundation for Statistical ComputingPlatform: x86_64-pc-linux-gnu (64-bit)R is free software and comes with ABSOLUTELY NO WARRANTY.You are welcome to redistribute it under certain conditions.Type 'license()' or 'licence()' for distribution details.R is a collaborative project with many contributors.Type 'contributors()' for more information and'citation()' on how to cite R or R packages in publications.Type 'demo()' for some demos, 'help()' for on-line help, or'help.start()' for an HTML browser interface to help.Type 'q()' to quit R.> library(cluster)> ## Compare on these:> nms <- c("clustering", "objective", "isolation", "clusinfo", "silinfo")> nm2 <- c("medoids", "id.med", nms)> nm3 <- nm2[- pmatch("obj", nm2)]>> (x <- x0 <- cbind(V1 = (-3:4)^2, V2 = c(0:6,NA), V3 = c(1,2,NA,7,NA,8:9,8)))V1 V2 V3[1,] 9 0 1[2,] 4 1 2[3,] 1 2 NA[4,] 0 3 7[5,] 1 4 NA[6,] 4 5 8[7,] 9 6 9[8,] 16 NA 8> (px <- pam(x,2, metric="manhattan"))Medoids:ID V1 V2 V3[1,] 2 4 1 2[2,] 6 4 5 8Clustering vector:[1] 1 1 1 2 2 2 2 2Objective function:build swap6.375 6.375Available components:[1] "medoids" "id.med" "clustering" "objective" "isolation"[6] "clusinfo" "silinfo" "diss" "call" "data"> stopifnot(identical(x,x0))# DUP=FALSE ..> pd <- pam(dist(x,"manhattan"), 2)> px2 <- pam(x,2, metric="manhattan", keep.diss=FALSE, keep.data=FALSE)> pdC <- pam(x,2, metric="manhattan", cluster.only = TRUE)> p1 <- pam(x,1, metric="manhattan")>> stopifnot(identical(px[nms], pd[nms]),+ identical(px[nms], px2[nms]),+ identical(pdC, px2$clustering),+ ## and for default dist "euclidean":+ identical(pam(x, 2)[nms],+ pam(dist(x),2)[nms]),+ identical(p1[c("id.med", "objective", "clusinfo")],+ list(id.med = 6L, objective = c(build=9.25, swap=9.25),+ clusinfo = array(c(8, 18, 9.25, 45, 0), dim = c(1, 5),+ dimnames=list(NULL, c("size", "max_diss", "av_diss",+ "diameter", "separation"))))),+ p1$clustering == 1, is.null(p1$silinfo)+ )>> set.seed(253)> ## generate 250 objects, divided into 2 clusters.> x <- rbind(cbind(rnorm(120, 0,8), rnorm(120, 0,8)),+ cbind(rnorm(130,50,8), rnorm(130,10,8)))>> .proctime00 <- proc.time()>> summary(px2 <- pam(x, 2))Medoids:ID[1,] 61 -0.7697828 -0.2330187[2,] 163 49.1392167 9.4097259Clustering vector:[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1[38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1[75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1[112] 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2[149] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2[186] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2[223] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2Objective function:build swap13.25843 10.20817Numerical information per cluster:size max_diss av_diss diameter separation[1,] 120 31.04843 10.18584 53.22082 9.419035[2,] 130 26.94337 10.22878 47.86442 9.419035Isolated clusters:L-clusters: character(0)L*-clusters: character(0)Silhouette plot information:cluster neighbor sil_width117 1 2 0.8063896675 1 2 0.8060082481 1 2 0.80556624107 1 2 0.805352526 1 2 0.80526675100 1 2 0.8038550568 1 2 0.80369702113 1 2 0.8033177461 1 2 0.8031532257 1 2 0.8031394512 1 2 0.8016157359 1 2 0.8004774582 1 2 0.7963096467 1 2 0.7955958963 1 2 0.7948888647 1 2 0.7945880921 1 2 0.793795409 1 2 0.7934308195 1 2 0.793321534 1 2 0.791360813 1 2 0.7913087939 1 2 0.79052367120 1 2 0.7887742390 1 2 0.7876722485 1 2 0.78588359106 1 2 0.7850445292 1 2 0.7830300083 1 2 0.7824591519 1 2 0.7822835914 1 2 0.7813923610 1 2 0.7782567849 1 2 0.7759708764 1 2 0.7748276144 1 2 0.7739739489 1 2 0.77297318119 1 2 0.77238705108 1 2 0.77137189104 1 2 0.7687137832 1 2 0.76856251115 1 2 0.7684331227 1 2 0.7681169888 1 2 0.76810713109 1 2 0.7668130362 1 2 0.7665595436 1 2 0.7654798866 1 2 0.7653560674 1 2 0.7649140626 1 2 0.7644145524 1 2 0.7643618865 1 2 0.7638135240 1 2 0.7606110952 1 2 0.7574867954 1 2 0.7574643613 1 2 0.7559407356 1 2 0.7535378496 1 2 0.75268786116 1 2 0.75267215110 1 2 0.75266614112 1 2 0.7515087278 1 2 0.750837087 1 2 0.7490518786 1 2 0.7419042418 1 2 0.74162144111 1 2 0.7408547469 1 2 0.7404465376 1 2 0.7391170750 1 2 0.7384707593 1 2 0.7361638431 1 2 0.7346200733 1 2 0.7345525243 1 2 0.73396232102 1 2 0.72930751118 1 2 0.7277802315 1 2 0.7258812253 1 2 0.725423638 1 2 0.7253519177 1 2 0.7246780916 1 2 0.7244695248 1 2 0.72331213105 1 2 0.7232509537 1 2 0.72055248101 1 2 0.7178356222 1 2 0.7121755223 1 2 0.7107837584 1 2 0.7057335217 1 2 0.7022194638 1 2 0.699472402 1 2 0.6971878098 1 2 0.696012371 1 2 0.6937384135 1 2 0.6917954670 1 2 0.6907491528 1 2 0.6843409197 1 2 0.683519785 1 2 0.6766267572 1 2 0.6742072234 1 2 0.6731526711 1 2 0.67226046103 1 2 0.6718866887 1 2 0.6717280258 1 2 0.6709051346 1 2 0.6683511660 1 2 0.6656544580 1 2 0.6598384273 1 2 0.6509394755 1 2 0.6470922620 1 2 0.6443940145 1 2 0.6340336151 1 2 0.6330310142 1 2 0.6290626894 1 2 0.6091640691 1 2 0.5990599641 1 2 0.5724548529 1 2 0.5559478199 1 2 0.5503595579 1 2 0.5080854471 1 2 0.4666395425 1 2 0.43797346114 1 2 0.1664500330 1 2 0.08928664121 2 1 0.80353953137 2 1 0.80253721146 2 1 0.80106653173 2 1 0.80039417216 2 1 0.79969919124 2 1 0.79964913163 2 1 0.79901674157 2 1 0.79779188242 2 1 0.79744315227 2 1 0.79708130207 2 1 0.79653829130 2 1 0.79574204188 2 1 0.79496670250 2 1 0.79302877145 2 1 0.79190501126 2 1 0.79156003166 2 1 0.79068795222 2 1 0.78986170232 2 1 0.78839216176 2 1 0.78819086198 2 1 0.78782877225 2 1 0.78747329230 2 1 0.78689375205 2 1 0.78683641160 2 1 0.78643596150 2 1 0.78484046136 2 1 0.78455577228 2 1 0.78198238206 2 1 0.78137390152 2 1 0.78044944200 2 1 0.77843458149 2 1 0.77822272221 2 1 0.77758324226 2 1 0.77611981129 2 1 0.77531368199 2 1 0.77491451154 2 1 0.77136276241 2 1 0.77076783179 2 1 0.77010597174 2 1 0.76893758214 2 1 0.76776510181 2 1 0.76763087213 2 1 0.76683151215 2 1 0.76639087236 2 1 0.76637552218 2 1 0.76563050182 2 1 0.76450873219 2 1 0.76370712208 2 1 0.76090426151 2 1 0.75957536164 2 1 0.75914844248 2 1 0.75849775224 2 1 0.75826151168 2 1 0.75782023189 2 1 0.75555083128 2 1 0.75550519125 2 1 0.75510766177 2 1 0.75128941147 2 1 0.75086382158 2 1 0.75029192245 2 1 0.74993652186 2 1 0.74741247165 2 1 0.74681005156 2 1 0.74478894122 2 1 0.74315425247 2 1 0.74107328220 2 1 0.74054057183 2 1 0.73818743184 2 1 0.73743259169 2 1 0.73712431180 2 1 0.73419669240 2 1 0.73390938134 2 1 0.73382823190 2 1 0.73379720217 2 1 0.73311931171 2 1 0.73110365143 2 1 0.72986022153 2 1 0.72891371223 2 1 0.72887340238 2 1 0.72789416175 2 1 0.72311665138 2 1 0.72290131235 2 1 0.72157157237 2 1 0.71591233132 2 1 0.71549875204 2 1 0.71381083201 2 1 0.71263881170 2 1 0.70812568191 2 1 0.70747428243 2 1 0.70588929193 2 1 0.70499170141 2 1 0.70489885161 2 1 0.70303117249 2 1 0.69300988229 2 1 0.69231982196 2 1 0.69162302211 2 1 0.69128644246 2 1 0.68757678159 2 1 0.68619850133 2 1 0.68605444194 2 1 0.68538064155 2 1 0.68278455234 2 1 0.68202095127 2 1 0.68111027144 2 1 0.67559517131 2 1 0.65959281139 2 1 0.65895024209 2 1 0.65844942148 2 1 0.65180336185 2 1 0.64989675212 2 1 0.63954685192 2 1 0.63470144123 2 1 0.63005333202 2 1 0.61735843135 2 1 0.61493992210 2 1 0.60680456140 2 1 0.58410004187 2 1 0.58193543239 2 1 0.57088679203 2 1 0.56761998244 2 1 0.55321123231 2 1 0.55043439197 2 1 0.52364031195 2 1 0.51955678142 2 1 0.47466260162 2 1 0.46155841172 2 1 0.45167576178 2 1 0.42686872233 2 1 0.37013099167 2 1 0.32442373Average silhouette width per cluster:[1] 0.7196104 0.7148520Average silhouette width of total data set:[1] 0.717136Available components:[1] "medoids" "id.med" "clustering" "objective" "isolation"[6] "clusinfo" "silinfo" "diss" "call" "data"> pdx <- pam(dist(x), 2)> all.equal(px2[nms], pdx[nms], tol = 1e-12) ## TRUE[1] TRUE> pdxK <- pam(dist(x), 2, keep.diss = TRUE)> stopifnot(identical(pdx[nm2], pdxK[nm2]))>> spdx <- silhouette(pdx)> summary(spdx)Silhouette of 250 units in 2 clusters from pam(x = dist(x), k = 2) :Cluster sizes and average silhouette widths:120 1300.7196104 0.7148520Individual silhouette widths:Min. 1st Qu. Median Mean 3rd Qu. Max.0.08929 0.69137 0.74397 0.71714 0.77806 0.80639> spdxcluster neighbor sil_width117 1 2 0.8063896675 1 2 0.8060082481 1 2 0.80556624107 1 2 0.805352526 1 2 0.80526675100 1 2 0.8038550568 1 2 0.80369702113 1 2 0.8033177461 1 2 0.8031532257 1 2 0.8031394512 1 2 0.8016157359 1 2 0.8004774582 1 2 0.7963096467 1 2 0.7955958963 1 2 0.7948888647 1 2 0.7945880921 1 2 0.793795409 1 2 0.7934308195 1 2 0.793321534 1 2 0.791360813 1 2 0.7913087939 1 2 0.79052367120 1 2 0.7887742390 1 2 0.7876722485 1 2 0.78588359106 1 2 0.7850445292 1 2 0.7830300083 1 2 0.7824591519 1 2 0.7822835914 1 2 0.7813923610 1 2 0.7782567849 1 2 0.7759708764 1 2 0.7748276144 1 2 0.7739739489 1 2 0.77297318119 1 2 0.77238705108 1 2 0.77137189104 1 2 0.7687137832 1 2 0.76856251115 1 2 0.7684331227 1 2 0.7681169888 1 2 0.76810713109 1 2 0.7668130362 1 2 0.7665595436 1 2 0.7654798866 1 2 0.7653560674 1 2 0.7649140626 1 2 0.7644145524 1 2 0.7643618865 1 2 0.7638135240 1 2 0.7606110952 1 2 0.7574867954 1 2 0.7574643613 1 2 0.7559407356 1 2 0.7535378496 1 2 0.75268786116 1 2 0.75267215110 1 2 0.75266614112 1 2 0.7515087278 1 2 0.750837087 1 2 0.7490518786 1 2 0.7419042418 1 2 0.74162144111 1 2 0.7408547469 1 2 0.7404465376 1 2 0.7391170750 1 2 0.7384707593 1 2 0.7361638431 1 2 0.7346200733 1 2 0.7345525243 1 2 0.73396232102 1 2 0.72930751118 1 2 0.7277802315 1 2 0.7258812253 1 2 0.725423638 1 2 0.7253519177 1 2 0.7246780916 1 2 0.7244695248 1 2 0.72331213105 1 2 0.7232509537 1 2 0.72055248101 1 2 0.7178356222 1 2 0.7121755223 1 2 0.7107837584 1 2 0.7057335217 1 2 0.7022194638 1 2 0.699472402 1 2 0.6971878098 1 2 0.696012371 1 2 0.6937384135 1 2 0.6917954670 1 2 0.6907491528 1 2 0.6843409197 1 2 0.683519785 1 2 0.6766267572 1 2 0.6742072234 1 2 0.6731526711 1 2 0.67226046103 1 2 0.6718866887 1 2 0.6717280258 1 2 0.6709051346 1 2 0.6683511660 1 2 0.6656544580 1 2 0.6598384273 1 2 0.6509394755 1 2 0.6470922620 1 2 0.6443940145 1 2 0.6340336151 1 2 0.6330310142 1 2 0.6290626894 1 2 0.6091640691 1 2 0.5990599641 1 2 0.5724548529 1 2 0.5559478199 1 2 0.5503595579 1 2 0.5080854471 1 2 0.4666395425 1 2 0.43797346114 1 2 0.1664500330 1 2 0.08928664121 2 1 0.80353953137 2 1 0.80253721146 2 1 0.80106653173 2 1 0.80039417216 2 1 0.79969919124 2 1 0.79964913163 2 1 0.79901674157 2 1 0.79779188242 2 1 0.79744315227 2 1 0.79708130207 2 1 0.79653829130 2 1 0.79574204188 2 1 0.79496670250 2 1 0.79302877145 2 1 0.79190501126 2 1 0.79156003166 2 1 0.79068795222 2 1 0.78986170232 2 1 0.78839216176 2 1 0.78819086198 2 1 0.78782877225 2 1 0.78747329230 2 1 0.78689375205 2 1 0.78683641160 2 1 0.78643596150 2 1 0.78484046136 2 1 0.78455577228 2 1 0.78198238206 2 1 0.78137390152 2 1 0.78044944200 2 1 0.77843458149 2 1 0.77822272221 2 1 0.77758324226 2 1 0.77611981129 2 1 0.77531368199 2 1 0.77491451154 2 1 0.77136276241 2 1 0.77076783179 2 1 0.77010597174 2 1 0.76893758214 2 1 0.76776510181 2 1 0.76763087213 2 1 0.76683151215 2 1 0.76639087236 2 1 0.76637552218 2 1 0.76563050182 2 1 0.76450873219 2 1 0.76370712208 2 1 0.76090426151 2 1 0.75957536164 2 1 0.75914844248 2 1 0.75849775224 2 1 0.75826151168 2 1 0.75782023189 2 1 0.75555083128 2 1 0.75550519125 2 1 0.75510766177 2 1 0.75128941147 2 1 0.75086382158 2 1 0.75029192245 2 1 0.74993652186 2 1 0.74741247165 2 1 0.74681005156 2 1 0.74478894122 2 1 0.74315425247 2 1 0.74107328220 2 1 0.74054057183 2 1 0.73818743184 2 1 0.73743259169 2 1 0.73712431180 2 1 0.73419669240 2 1 0.73390938134 2 1 0.73382823190 2 1 0.73379720217 2 1 0.73311931171 2 1 0.73110365143 2 1 0.72986022153 2 1 0.72891371223 2 1 0.72887340238 2 1 0.72789416175 2 1 0.72311665138 2 1 0.72290131235 2 1 0.72157157237 2 1 0.71591233132 2 1 0.71549875204 2 1 0.71381083201 2 1 0.71263881170 2 1 0.70812568191 2 1 0.70747428243 2 1 0.70588929193 2 1 0.70499170141 2 1 0.70489885161 2 1 0.70303117249 2 1 0.69300988229 2 1 0.69231982196 2 1 0.69162302211 2 1 0.69128644246 2 1 0.68757678159 2 1 0.68619850133 2 1 0.68605444194 2 1 0.68538064155 2 1 0.68278455234 2 1 0.68202095127 2 1 0.68111027144 2 1 0.67559517131 2 1 0.65959281139 2 1 0.65895024209 2 1 0.65844942148 2 1 0.65180336185 2 1 0.64989675212 2 1 0.63954685192 2 1 0.63470144123 2 1 0.63005333202 2 1 0.61735843135 2 1 0.61493992210 2 1 0.60680456140 2 1 0.58410004187 2 1 0.58193543239 2 1 0.57088679203 2 1 0.56761998244 2 1 0.55321123231 2 1 0.55043439197 2 1 0.52364031195 2 1 0.51955678142 2 1 0.47466260162 2 1 0.46155841172 2 1 0.45167576178 2 1 0.42686872233 2 1 0.37013099167 2 1 0.32442373attr(,"Ordered")[1] TRUEattr(,"call")pam(x = dist(x), k = 2)attr(,"class")[1] "silhouette"> postscript("pam-tst.ps")> if(FALSE)+ plot(spdx)# the silhouette> ## is now identical :> plot(pdx)# failed in 1.7.0 -- now only does silhouette>> par(mfrow = 2:1)> ## new 'dist' argument for clusplot():> plot(pdx, dist=dist(x))> ## but this should work automagically (via eval()) as well:> plot(pdx)> ## or this> clusplot(pdx)>> data(ruspini)> summary(pr4 <- pam(ruspini, 4))Medoids:ID x y10 10 19 6532 32 44 14952 52 99 11970 70 69 21Clustering vector:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 227 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 522 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 353 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 753 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4Objective function:build swap17.22898 11.48637Numerical information per cluster:size max_diss av_diss diameter separation[1,] 20 24.04163 12.55362 40.24922 40.49691[2,] 23 26.92582 10.44238 36.61967 24.04163[3,] 17 33.97058 13.84800 47.63402 24.04163[4,] 15 17.02939 8.98767 27.07397 40.49691Isolated clusters:L-clusters: character(0)L*-clusters: [1] 1 4Silhouette plot information:cluster neighbor sil_width10 1 4 0.80560966 1 4 0.79549779 1 4 0.792304811 1 4 0.78316728 1 2 0.781179312 1 4 0.76581713 1 4 0.758796114 1 4 0.75691072 1 4 0.745615016 1 4 0.743601813 1 4 0.73988414 1 2 0.736153318 1 4 0.708007915 1 4 0.700685419 1 4 0.70009381 1 4 0.67983815 1 4 0.664657120 1 4 0.661962617 1 4 0.61485417 1 2 0.590057526 2 3 0.835743332 2 3 0.833275327 2 3 0.829027125 2 3 0.828554728 2 3 0.819263635 2 3 0.818630933 2 3 0.817508723 2 3 0.808996922 2 3 0.802538934 2 3 0.801331031 2 3 0.794967736 2 3 0.794353624 2 3 0.793077029 2 3 0.789734630 2 3 0.789202721 2 3 0.769802437 2 3 0.768450239 2 3 0.763164838 2 3 0.743884840 2 3 0.708313042 2 3 0.529127043 2 3 0.493162341 2 3 0.429081454 3 2 0.774174557 3 2 0.770345555 3 2 0.764181050 3 2 0.761994352 3 2 0.761622056 3 2 0.757531359 3 2 0.732782849 3 2 0.731700251 3 2 0.720986460 3 2 0.720684058 3 2 0.701961153 3 2 0.677532245 3 2 0.597478746 3 2 0.574082347 3 2 0.483563548 3 2 0.424733144 3 2 0.419609370 4 1 0.854894767 4 1 0.852743965 4 1 0.850310569 4 1 0.839181071 4 1 0.838106566 4 1 0.822984162 4 1 0.815309264 4 1 0.806125473 4 1 0.795021363 4 1 0.779536972 4 1 0.774812161 4 1 0.770110368 4 1 0.762055974 4 1 0.759681575 4 1 0.7425538Average silhouette width per cluster:[1] 0.7262347 0.7548344 0.6691154 0.8042285Average silhouette width of total data set:[1] 0.7376572775 dissimilarities, summarized :Min. 1st Qu. Median Mean 3rd Qu. Max.1.414 40.106 75.591 71.538 99.169 154.500Metric : euclideanNumber of objects : 75Available components:[1] "medoids" "id.med" "clustering" "objective" "isolation"[6] "clusinfo" "silinfo" "diss" "call" "data"> (pr3 <- pam(ruspini, 3))Medoids:ID x y17 17 30 5232 32 44 14952 52 99 119Clustering vector:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 227 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 522 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 353 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 753 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1Objective function:build swap25.68229 21.59293Available components:[1] "medoids" "id.med" "clustering" "objective" "isolation"[6] "clusinfo" "silinfo" "diss" "call" "data"> (pr5 <- pam(ruspini, 5))Medoids:ID x y10 10 19 6532 32 44 14952 52 99 11947 47 78 9470 70 69 21Clustering vector:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 227 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 522 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 4 4 4 3 3 3 353 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 753 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5Objective function:build swap12.09864 10.39579Available components:[1] "medoids" "id.med" "clustering" "objective" "isolation"[6] "clusinfo" "silinfo" "diss" "call" "data">> data(votes.repub)> summary(pv3 <- pam(votes.repub, 3))Medoids:ID X1856 X1860 X1864 X1868 X1872 X1876 X1880 X1884 X1888 X1892 X1896Alabama 1 NA NA NA 51.44 53.19 40.02 36.98 38.44 32.28 3.95 28.13Alaska 2 NA NA NA NA NA NA NA NA NA NA NANew Mexico 31 NA NA NA NA NA NA NA NA NA NA NAX1900 X1904 X1908 X1912 X1916 X1920 X1924 X1928 X1932 X1936 X1940Alabama 34.67 20.65 24.38 8.26 21.97 30.98 27.01 48.49 14.15 12.82 14.34Alaska NA NA NA NA NA NA NA NA NA NA NANew Mexico NA NA NA 35.91 46.53 54.68 48.52 59.01 35.76 36.50 43.28X1944 X1948 X1952 X1956 X1960 X1964 X1968 X1972 X1976Alabama 18.20 19.04 35.02 39.39 41.75 69.5 14.0 72.4 43.48Alaska NA NA NA NA 50.94 34.1 45.3 58.1 62.91New Mexico 46.44 42.93 55.39 57.81 49.41 41.0 51.8 61.0 51.04Clustering vector:Alabama Alaska Arizona Arkansas California1 2 3 1 2Colorado Connecticut Delaware Florida Georgia2 2 3 1 1Hawaii Idaho Illinois Indiana Iowa2 3 2 3 3Kansas Kentucky Louisiana Maine Maryland2 3 1 2 3Massachusetts Michigan Minnesota Mississippi Missouri3 2 3 1 3Montana Nebraska Nevada New Hampshire New Jersey3 3 2 2 2New Mexico New York North Carolina North Dakota Ohio3 3 3 2 3Oklahoma Oregon Pennsylvania Rhode Island South Carolina3 3 2 3 2South Dakota Tennessee Texas Utah Vermont3 3 2 3 2Virginia Washington West Virginia Wisconsin Wyoming2 3 3 3 3Objective function:build swap38.32548 38.32548Numerical information per cluster:size max_diss av_diss diameter separation[1,] 6 78.92731 51.59134 116.7048 50.14189[2,] 18 86.54675 38.47068 271.2455 19.42184[3,] 26 60.03879 35.16361 124.8324 19.42184Isolated clusters:L-clusters: character(0)L*-clusters: character(0)Silhouette plot information:cluster neighbor sil_widthLouisiana 1 3 0.54689535Alabama 1 3 0.52839272Georgia 1 3 0.52730253Mississippi 1 2 0.52454810Florida 1 3 0.25211631Arkansas 1 3 0.24131701Alaska 2 3 0.15699268Hawaii 2 3 0.08479842Vermont 2 3 -0.02620975Maine 2 3 -0.03284950Michigan 2 3 -0.11524982Pennsylvania 2 3 -0.15341477New Hampshire 2 3 -0.17099889Connecticut 2 3 -0.19095000New Jersey 2 3 -0.19281567Kansas 2 3 -0.19719316California 2 3 -0.24006293Illinois 2 3 -0.25236336North Dakota 2 3 -0.25464430Virginia 2 3 -0.26262534Nevada 2 3 -0.27016336Colorado 2 3 -0.27885043Texas 2 1 -0.47297583South Carolina 2 1 -0.50899710New Mexico 3 2 0.39555584Washington 3 2 0.32989454Oklahoma 3 2 0.30953823Wyoming 3 2 0.30163169Idaho 3 2 0.29915132Montana 3 2 0.29105494Missouri 3 2 0.29038462Oregon 3 2 0.27710695Maryland 3 2 0.27437520West Virginia 3 2 0.27089938Utah 3 2 0.26964380Tennessee 3 2 0.26846440Arizona 3 2 0.25968564Delaware 3 2 0.25920434Kentucky 3 2 0.25868341South Dakota 3 2 0.25615670Indiana 3 2 0.25031548Wisconsin 3 2 0.21808013Ohio 3 2 0.21477474Nebraska 3 2 0.20965953North Carolina 3 2 0.19201537Minnesota 3 2 0.18955165New York 3 2 0.18820394Iowa 3 2 0.17296046Rhode Island 3 2 0.12599915Massachusetts 3 2 0.12106770Average silhouette width per cluster:[1] 0.4367620 -0.1876985 0.2497715Average silhouette width of total data set:[1] 0.11472121225 dissimilarities, summarized :Min. 1st Qu. Median Mean 3rd Qu. Max.17.20 48.34 64.68 82.23 105.49 281.95Metric : euclideanNumber of objects : 50Available components:[1] "medoids" "id.med" "clustering" "objective" "isolation"[6] "clusinfo" "silinfo" "diss" "call" "data"> (pv4 <- pam(votes.repub, 4))Medoids:ID X1856 X1860 X1864 X1868 X1872 X1876 X1880 X1884 X1888 X1892 X1896Alabama 1 NA NA NA 51.44 53.19 40.02 36.98 38.44 32.28 3.95 28.13Alaska 2 NA NA NA NA NA NA NA NA NA NA NANew Mexico 31 NA NA NA NA NA NA NA NA NA NA NAIowa 15 49.13 54.87 64.23 61.92 64.18 58.58 56.85 52.42 52.36 49.60 55.46X1900 X1904 X1908 X1912 X1916 X1920 X1924 X1928 X1932 X1936 X1940Alabama 34.67 20.65 24.38 8.26 21.97 30.98 27.01 48.49 14.15 12.82 14.34Alaska NA NA NA NA NA NA NA NA NA NA NANew Mexico NA NA NA 35.91 46.53 54.68 48.52 59.01 35.76 36.50 43.28Iowa 57.99 63.37 55.62 24.30 54.06 70.91 55.06 61.80 39.98 42.70 52.03X1944 X1948 X1952 X1956 X1960 X1964 X1968 X1972 X1976Alabama 18.20 19.04 35.02 39.39 41.75 69.5 14.0 72.4 43.48Alaska NA NA NA NA 50.94 34.1 45.3 58.1 62.91New Mexico 46.44 42.93 55.39 57.81 49.41 41.0 51.8 61.0 51.04Iowa 51.99 47.58 63.76 59.06 56.71 38.1 53.0 57.6 50.51Clustering vector:Alabama Alaska Arizona Arkansas California1 2 3 1 2Colorado Connecticut Delaware Florida Georgia2 2 3 1 1Hawaii Idaho Illinois Indiana Iowa2 3 4 3 4Kansas Kentucky Louisiana Maine Maryland4 3 1 2 3Massachusetts Michigan Minnesota Mississippi Missouri4 2 4 1 3Montana Nebraska Nevada New Hampshire New Jersey3 4 2 2 2New Mexico New York North Carolina North Dakota Ohio3 3 3 4 4Oklahoma Oregon Pennsylvania Rhode Island South Carolina3 3 4 4 2South Dakota Tennessee Texas Utah Vermont4 3 2 3 2Virginia Washington West Virginia Wisconsin Wyoming2 3 3 4 3Objective function:build swap35.84182 35.84182Available components:[1] "medoids" "id.med" "clustering" "objective" "isolation"[6] "clusinfo" "silinfo" "diss" "call" "data"> (pv6 <- pam(votes.repub, 6, trace = 3))C pam(): computing 1226 dissimilarities from 50 x 31 matrix: [Ok]pam()'s bswap(*, s=281.951, pamonce=0): build 6 medoids:new repr. 2new repr. 1new repr. 31new repr. 15new repr. 46new repr. 40after build: medoids are 1 2 15 31 40 46and min.dist dysma[1:n] are0 0 37.7 56 35.8 28.5 28.6 31.7 54.1 48.251.7 33.2 27.3 30.5 0 35.1 25.4 60.9 36.9 26.748.4 28.1 33.2 63.1 21.1 28.6 37.5 35.8 29.8 31.30 32 29.9 35.7 30.9 35.1 27.8 35.7 50.2 026.2 30.2 45.2 34.1 33.8 0 28.5 35.1 34.2 28.8swp new 10 <-> 1 old; decreasing diss. 1579.03 by -2.57067end{bswap()}, end{cstat()}Medoids:ID X1856 X1860 X1864 X1868 X1872 X1876 X1880 X1884 X1888 X1892Georgia 10 NA NA NA 35.72 43.77 27.94 34.33 33.84 28.33 21.80Alaska 2 NA NA NA NA NA NA NA NA NA NAVirginia 46 0.19 1.15 NA NA 50.48 40.62 39.52 48.90 49.47 38.75New Mexico 31 NA NA NA NA NA NA NA NA NA NAIowa 15 49.13 54.87 64.23 61.92 64.18 58.58 56.85 52.42 52.36 49.60South Carolina 40 NA NA NA 57.93 75.95 50.26 33.97 23.72 17.27 18.99X1896 X1900 X1904 X1908 X1912 X1916 X1920 X1924 X1928 X1932Georgia 36.82 28.56 18.32 31.40 4.27 7.07 28.57 18.19 43.37 7.77Alaska NA NA NA NA NA NA NA NA NA NAVirginia 45.90 43.81 36.67 38.36 17.00 32.05 37.85 32.79 53.91 30.09New Mexico NA NA NA NA 35.91 46.53 54.68 48.52 59.01 35.76Iowa 55.46 57.99 63.37 55.62 24.30 54.06 70.91 55.06 61.80 39.98South Carolina 13.51 7.04 4.63 5.97 1.06 2.43 3.90 2.21 8.54 1.89X1936 X1940 X1944 X1948 X1952 X1956 X1960 X1964 X1968 X1972Georgia 12.60 14.84 18.25 18.31 30.34 33.22 37.44 54.1 30.4 75.0Alaska NA NA NA NA NA NA 50.94 34.1 45.3 58.1Virginia 29.39 31.55 37.39 41.04 56.32 55.37 52.44 46.5 41.4 67.8New Mexico 36.50 43.28 46.44 42.93 55.39 57.81 49.41 41.0 51.8 61.0Iowa 42.70 52.03 51.99 47.58 63.76 59.06 56.71 38.1 53.0 57.6South Carolina 1.43 4.37 4.46 3.78 49.28 25.18 48.76 58.9 38.1 70.8X1976Georgia 33.02Alaska 62.91Virginia 50.73New Mexico 51.04Iowa 50.51South Carolina 43.54Clustering vector:Alabama Alaska Arizona Arkansas California1 2 3 3 2Colorado Connecticut Delaware Florida Georgia2 2 4 3 1Hawaii Idaho Illinois Indiana Iowa2 4 5 4 5Kansas Kentucky Louisiana Maine Maryland5 4 1 2 4Massachusetts Michigan Minnesota Mississippi Missouri5 2 5 6 4Montana Nebraska Nevada New Hampshire New Jersey4 5 2 2 2New Mexico New York North Carolina North Dakota Ohio4 4 3 5 5Oklahoma Oregon Pennsylvania Rhode Island South Carolina4 4 5 5 6South Dakota Tennessee Texas Utah Vermont5 3 2 4 2Virginia Washington West Virginia Wisconsin Wyoming3 4 4 5 4Objective function:build swap31.58067 31.52926Available components:[1] "medoids" "id.med" "clustering" "objective" "isolation"[6] "clusinfo" "silinfo" "diss" "call" "data">> cat('Time elapsed: ', proc.time() - .proctime00,'\n')Time elapsed: 0.392 0.016 0.41 0 0>> ## re-starting with medoids from pv6 shouldn't change:> pv6. <- pam(votes.repub, 6, medoids = pv6$id.med, trace = 3)C pam(): computing 1226 dissimilarities from 50 x 31 matrix: [Ok]pam()'s bswap(*, s=281.951, pamonce=0): medoids given; after build: medoids are 2 10 15 31 40 46and min.dist dysma[1:n] are48.2 0 37.7 56 35.8 28.5 28.6 31.7 54.1 051.7 33.2 27.3 30.5 0 35.1 25.4 58.3 36.9 26.748.4 28.1 33.2 63.1 21.1 28.6 37.5 35.8 29.8 31.30 32 29.9 35.7 30.9 35.1 27.8 35.7 50.2 026.2 30.2 45.2 34.1 33.8 0 28.5 35.1 34.2 28.8end{bswap()}, end{cstat()}> identical(pv6[nm3], pv6.[nm3])[1] TRUE>> ## This example seg.faulted at some point:> d.st <- data.frame(V1= c(9, 12, 12, 15, 9, 9, 13, 11, 15, 10, 13, 13,+ 13, 15, 8, 13, 13, 10, 7, 9, 6, 11, 3),+ V2= c(5, 9, 3, 5, 1, 1, 2, NA, 10, 1, 4, 7,+ 4, NA, NA, 5, 2, 4, 3, 3, 6, 1, 1),+ V3 = c(63, 41, 59, 50, 290, 226, 60, 36, 32, 121, 70, 51,+ 79, 32, 42, 39, 76, 60, 56, 88, 57, 309, 254),+ V4 = c(146, 43, 78, 88, 314, 149, 78, NA, 238, 153, 159, 222,+ 203, NA, NA, 74, 100, 111, 9, 180, 50, 256, 107))> dd <- daisy(d.st, stand = TRUE)> (r0 <- pam(dd, 5))# cluster 5 = { 23 } -- on single observationMedoids:ID[1,] 15 15[2,] 8 8[3,] 14 14[4,] 22 22[5,] 23 23Clustering vector:[1] 1 2 2 3 4 4 2 2 3 2 2 2 2 3 1 2 2 2 1 1 1 4 5Objective function:build swap0.9368049 0.8621860Available components:[1] "medoids" "id.med" "clustering" "objective" "isolation"[6] "clusinfo" "silinfo" "diss" "call"> ## pam doing the "daisy" computation internally:> r0s <- pam(d.st, 5, stand=TRUE, keep.diss=FALSE, keep.data=FALSE)> (ii <- which(names(r0) %in% c("call","medoids")))[1] 1 9> stopifnot(all.equal(r0[-ii], r0s[-ii], tol=1e-14),+ identical(r0s$medoids, data.matrix(d.st)[r0$medoids, ]))>> ## This gave only 3 different medoids -> and seg.fault:> (r5 <- pam(dd, 5, medoids = c(1,3,20,2,5), trace = 2)) # now "fine"pam()'s bswap(*, s=8.51931, pamonce=0): medoids given; after build: medoids are 1 2 3 5 20swp new 14 <-> 2 old; decreasing diss. 29.8745 by -5.50096swp new 15 <-> 1 old; decreasing diss. 24.3735 by -2.20162swp new 6 <-> 20 old; decreasing diss. 22.1719 by -2.12745swp new 8 <-> 3 old; decreasing diss. 20.0444 by -0.201608end{bswap()}, end{cstat()}Medoids:ID[1,] 15 15[2,] 8 8[3,] 14 14[4,] 5 5[5,] 6 6Clustering vector:[1] 1 2 2 3 4 5 2 2 3 5 2 2 2 3 1 2 2 2 1 1 1 4 5Objective function:build swap1.2988899 0.8627319Available components:[1] "medoids" "id.med" "clustering" "objective" "isolation"[6] "clusinfo" "silinfo" "diss" "call">> dev.off()null device1>> ##------------------------ Testing pam() with new "pamonce" argument:>> ## This is from "next version of Matrix" test-tools-1.R:> showSys.time <- function(expr) {+ ## prepend 'Time' for R CMD Rdiff+ st <- system.time(expr)+ writeLines(paste("Time", capture.output(print(st))))+ invisible(st)+ }> show6Ratios <- function(...) {+ stopifnot(length(rgs <- list(...)) == 6,+ nchar(ns <- names(rgs)) > 0)+ r <- round(cbind(..1, ..2, ..3, ..4, ..5, ..6)[c(1,5),], 5)+ dimnames(r) <- list(paste("Time ", rownames(r)), ns)+ r+ }>>> n <- 1000> ## If not enough cases, all CPU times equals 0.> n <- 500 # for now, and automatic testing>> sd <- 0.5> set.seed(13)> n2 <- as.integer(round(n * 1.5))> x <- rbind(cbind(rnorm( n,0,sd), rnorm( n,0,sd)),+ cbind(rnorm(n2,5,sd), rnorm(n2,5,sd)),+ cbind(rnorm(n2,7,sd), rnorm(n2,7,sd)),+ cbind(rnorm(n2,9,sd), rnorm(n2,9,sd)))>>> ## original algorithm> st0 <- showSys.time(pamx <- pam(x, 4, trace.lev=2))# 8.157 0.024 8.233C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=0): build 4 medoids:new repr. 1268new repr. 414new repr. 2153new repr. 915after build: medoids are 414 915 1268 2153swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13end{bswap()}, end{cstat()}Time user system elapsedTime 1.163 0.005 1.176> ## bswapPamOnce algorithm> st1 <- showSys.time(pamxonce <- pam(x, 4, pamonce=TRUE, trace.lev=2))# 6.122 0.024 6.181C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=1): build 4 medoids:new repr. 1268new repr. 414new repr. 2153new repr. 915after build: medoids are 414 915 1268 2153swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13end{bswap()}, end{cstat()}Time user system elapsedTime 0.882 0.015 0.908> ## bswapPamOnceDistIndice> st2 <- showSys.time(pamxonce2 <- pam(x, 4, pamonce = 2, trace.lev=2))# 4.101 0.024 4.151C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=2): build 4 medoids:new repr. 1268new repr. 414new repr. 2153new repr. 915after build: medoids are 414 915 1268 2153swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13end{bswap()}, end{cstat()}Time user system elapsedTime 0.741 0.000 0.746> ## bswapPamSchubert FastPAM1> st3 <- showSys.time(pamxonce3 <- pam(x, 4, pamonce = 3, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=3): build 4 medoids:new repr. 1268new repr. 414new repr. 2153new repr. 915after build: medoids are 414 915 1268 2153swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13end{bswap()}, end{cstat()}Time user system elapsedTime 0.560 0.001 0.566> ## bswapPamSchubert FastPAM2> st4 <- showSys.time(pamxonce4 <- pam(x, 4, pamonce = 4, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=4): build 4 medoids:new repr. 1268new repr. 414new repr. 2153new repr. 915after build: medoids are 414 915 1268 2153swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13end{bswap()}, end{cstat()}Time user system elapsedTime 0.637 0.000 0.643> ## bswapPamSchubert FastPAM2 with linearized memory access> st5 <- showSys.time(pamxonce5 <- pam(x, 4, pamonce = 5, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=5): build 4 medoids:new repr. 1268new repr. 414new repr. 2153new repr. 915after build: medoids are 414 915 1268 2153swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13end{bswap()}, end{cstat()}Time user system elapsedTime 0.494 0.000 0.498> ## bswapPamSchubert FasterPAM> st6 <- showSys.time(pamxonce6 <- pam(x, 4, pamonce = 6, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=6): build 4 medoids:new repr. 1268new repr. 414new repr. 2153new repr. 915after build: medoids are 414 915 1268 2153swp new 1251 <-> 1268 old; decreasing diss. 1862.37 by -27.6945swp new 1255 <-> 1251 old; decreasing diss. 1834.68 by -81.213swp new 1259 <-> 1255 old; decreasing diss. 1753.46 by -4.71205swp new 1265 <-> 1259 old; decreasing diss. 1748.75 by -1.5194swp new 1280 <-> 1265 old; decreasing diss. 1747.23 by -1.34867swp new 1300 <-> 1280 old; decreasing diss. 1745.88 by -9.69283swp new 1421 <-> 1300 old; decreasing diss. 1736.19 by -2.94296swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415end{bswap()}, end{cstat()}Time user system elapsedTime 0.483 0.001 0.488> show6Ratios('6:orig' = st6/st0, '5:orig' = st5/st0, '4:orig' = st4/st0, '3:orig' = st3/st0, '2:orig' = st2/st0, '1:orig' = st1/st0)6:orig 5:orig 4:orig 3:orig 2:orig 1:origTime user.self 0.41531 0.42476 0.54772 0.48151 0.63715 0.75838Time sys.child NaN NaN NaN NaN NaN NaN>> ## only call element is not equal> (icall <- which(names(pamx) == "call"))[1] 9> pamx[[icall]]pam(x = x, k = 4, trace.lev = 2)> stopifnot(all.equal(pamx [-icall], pamxonce [-icall]),+ all.equal(pamxonce[-icall], pamxonce2[-icall]),+ all.equal(pamxonce[-icall], pamxonce3[-icall]),+ all.equal(pamxonce[-icall], pamxonce4[-icall]),+ all.equal(pamxonce[-icall], pamxonce5[-icall]),+ all.equal(pamxonce[-icall], pamxonce6[-icall]))>> ## Same using specified medoids> (med0 <- 1 + round(n* c(0,1, 2.5, 4)))# lynne (~ 2010, AMD Phenom II X4 925)[1] 1 501 1251 2001> st0 <- showSys.time(pamxst <- pam(x, 4, medoids = med0, trace.lev=2))# 13.071 0.024 13.177C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=0): medoids given; after build: medoids are 1 501 1251 2001swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507swp new 1793 <-> 1251 old; decreasing diss. 1929.32 by -101.336swp new 414 <-> 1 old; decreasing diss. 1827.98 by -86.3404swp new 2153 <-> 2001 old; decreasing diss. 1741.64 by -8.40201end{bswap()}, end{cstat()}Time user system elapsedTime 1.720 0.000 1.732> st1 <- showSys.time(pamxoncest <- pam(x, 4, medoids = med0, pamonce=TRUE, trace.lev=2))# 8.503 0.024 8.578C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=1): medoids given; after build: medoids are 1 501 1251 2001swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507swp new 1793 <-> 1251 old; decreasing diss. 1929.32 by -101.336swp new 414 <-> 1 old; decreasing diss. 1827.98 by -86.3404swp new 2153 <-> 2001 old; decreasing diss. 1741.64 by -8.40201end{bswap()}, end{cstat()}Time user system elapsedTime 1.319 0.000 1.329> st2 <- showSys.time(pamxonce2st <- pam(x, 4, medoids = med0, pamonce=2, trace.lev=2))# 5.587 0.025 5.647C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=2): medoids given; after build: medoids are 1 501 1251 2001swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507swp new 1793 <-> 1251 old; decreasing diss. 1929.32 by -101.336swp new 414 <-> 1 old; decreasing diss. 1827.98 by -86.3404swp new 2153 <-> 2001 old; decreasing diss. 1741.64 by -8.40201end{bswap()}, end{cstat()}Time user system elapsedTime 0.915 0.001 0.922> st3 <- showSys.time(pamxonce3st <- pam(x, 4, medoids = med0, pamonce=3, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=3): medoids given; after build: medoids are 1 501 1251 2001swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507swp new 1793 <-> 1251 old; decreasing diss. 1929.32 by -101.336swp new 414 <-> 1 old; decreasing diss. 1827.98 by -86.3404swp new 2153 <-> 2001 old; decreasing diss. 1741.64 by -8.40201end{bswap()}, end{cstat()}Time user system elapsedTime 0.442 0.001 0.445> st4 <- showSys.time(pamxonce4st <- pam(x, 4, medoids = med0, pamonce=4, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=4): medoids given; after build: medoids are 1 501 1251 2001swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507fswp new 1421 <-> 1251 old; decreasing diss. 1929.32 by -101.326fswp new 414 <-> 1 old; decreasing diss. 1827.99 by -86.3404fswp new 2153 <-> 2001 old; decreasing diss. 1741.65 by -8.40546swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415end{bswap()}, end{cstat()}Time user system elapsedTime 0.329 0.000 0.331> st5 <- showSys.time(pamxonce5st <- pam(x, 4, medoids = med0, pamonce=5, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=5): medoids given; after build: medoids are 1 501 1251 2001swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507fswp new 1421 <-> 1251 old; decreasing diss. 1929.32 by -101.326fswp new 414 <-> 1 old; decreasing diss. 1827.99 by -86.3404fswp new 2153 <-> 2001 old; decreasing diss. 1741.65 by -8.40546swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415end{bswap()}, end{cstat()}Time user system elapsedTime 0.289 0.000 0.290> st6 <- showSys.time(pamxonce6st <- pam(x, 4, medoids = med0, pamonce=6, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=6): medoids given; after build: medoids are 1 501 1251 2001swp new 8 <-> 1 old; decreasing diss. 2126.83 by -33.2528swp new 12 <-> 8 old; decreasing diss. 2093.57 by -32.0203swp new 15 <-> 12 old; decreasing diss. 2061.55 by -2.88573swp new 16 <-> 15 old; decreasing diss. 2058.67 by -3.50571swp new 33 <-> 16 old; decreasing diss. 2055.16 by -0.382726swp new 56 <-> 33 old; decreasing diss. 2054.78 by -0.660581swp new 70 <-> 56 old; decreasing diss. 2054.12 by -9.63432swp new 86 <-> 70 old; decreasing diss. 2044.48 by -2.56554swp new 123 <-> 86 old; decreasing diss. 2041.92 by -1.30247swp new 414 <-> 123 old; decreasing diss. 2040.62 by -0.130313swp new 502 <-> 501 old; decreasing diss. 2040.49 by -36.5109swp new 507 <-> 502 old; decreasing diss. 2003.97 by -131.351swp new 509 <-> 507 old; decreasing diss. 1872.62 by -14.3528swp new 530 <-> 509 old; decreasing diss. 1858.27 by -7.60641swp new 542 <-> 530 old; decreasing diss. 1850.66 by -2.78128swp new 574 <-> 542 old; decreasing diss. 1847.88 by -4.18202swp new 913 <-> 574 old; decreasing diss. 1843.7 by -0.343729swp new 915 <-> 913 old; decreasing diss. 1843.36 by -0.378301swp new 1255 <-> 1251 old; decreasing diss. 1842.98 by -81.0222swp new 1259 <-> 1255 old; decreasing diss. 1761.96 by -4.71205swp new 1265 <-> 1259 old; decreasing diss. 1757.24 by -1.6954swp new 1280 <-> 1265 old; decreasing diss. 1755.55 by -1.25118swp new 1300 <-> 1280 old; decreasing diss. 1754.3 by -9.70566swp new 1421 <-> 1300 old; decreasing diss. 1744.59 by -2.93951swp new 1793 <-> 1421 old; decreasing diss. 1741.65 by -0.00984953swp new 2089 <-> 2001 old; decreasing diss. 1741.64 by -3.18091swp new 2153 <-> 2089 old; decreasing diss. 1738.46 by -5.2211end{bswap()}, end{cstat()}Time user system elapsedTime 0.227 0.000 0.228> show6Ratios('6:orig' = st6/st0, '5:orig' = st5/st0, '4:orig' = st4/st0, '3:orig' = st3/st0, '2:orig' = st2/st0, '1:orig' = st1/st0)6:orig 5:orig 4:orig 3:orig 2:orig 1:origTime user.self 0.13198 0.16802 0.19128 0.25698 0.53198 0.76686Time sys.child NaN NaN NaN NaN NaN NaN>> ## only call element is not equal> stopifnot(all.equal(pamxst [-icall], pamxoncest [-icall]),+ all.equal(pamxoncest[-icall], pamxonce2st[-icall]),+ all.equal(pamxoncest[-icall], pamxonce3st[-icall]),+ all.equal(pamxoncest[-icall], pamxonce4st[-icall]),+ all.equal(pamxoncest[-icall], pamxonce5st[-icall]),+ all.equal(pamxoncest[-icall], pamxonce6st[-icall]))>> ## Different starting values> med0 <- 1:4 # lynne (~ 2010, AMD Phenom II X4 925)> st0 <- showSys.time(pamxst <- pam(x, 4, medoids = med0, trace.lev=2))# 13.416 0.023 13.529C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=0): medoids given; after build: medoids are 1 2 3 4swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415end{bswap()}, end{cstat()}Time user system elapsedTime 1.727 0.000 1.732> st1 <- showSys.time(pamxoncest <- pam(x, 4, medoids = med0, pamonce=TRUE, trace.lev=2))# 8.384 0.024 8.459C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=1): medoids given; after build: medoids are 1 2 3 4swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415end{bswap()}, end{cstat()}Time user system elapsedTime 1.362 0.000 1.366> st2 <- showSys.time(pamxonce2st <- pam(x, 4, medoids = med0, pamonce=2, trace.lev=2))# 5.455 0.030 5.520C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=2): medoids given; after build: medoids are 1 2 3 4swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415end{bswap()}, end{cstat()}Time user system elapsedTime 0.926 0.000 0.929> st3 <- showSys.time(pamxonce3st <- pam(x, 4, medoids = med0, pamonce=3, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=3): medoids given; after build: medoids are 1 2 3 4swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415end{bswap()}, end{cstat()}Time user system elapsedTime 0.504 0.000 0.505> st4 <- showSys.time(pamxonce4st <- pam(x, 4, medoids = med0, pamonce=4, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=4): medoids given; after build: medoids are 1 2 3 4swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404fswp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415end{bswap()}, end{cstat()}Time user system elapsedTime 0.449 0.000 0.451> st5 <- showSys.time(pamxonce5st <- pam(x, 4, medoids = med0, pamonce=5, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=5): medoids given; after build: medoids are 1 2 3 4swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404fswp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415end{bswap()}, end{cstat()}Time user system elapsedTime 0.338 0.000 0.340> st6 <- showSys.time(pamxonce6st <- pam(x, 4, medoids = med0, pamonce=6, trace.lev=2))#C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=6): medoids given; after build: medoids are 1 2 3 4swp new 7 <-> 3 old; decreasing diss. 21009.4 by -4.9986swp new 8 <-> 2 old; decreasing diss. 21004.4 by -16.4723swp new 11 <-> 7 old; decreasing diss. 20987.9 by -12.0798swp new 12 <-> 8 old; decreasing diss. 20975.9 by -3.31491swp new 13 <-> 1 old; decreasing diss. 20972.5 by -4.88251swp new 14 <-> 13 old; decreasing diss. 20967.7 by -1.90148swp new 15 <-> 14 old; decreasing diss. 20965.8 by -9.59363swp new 22 <-> 11 old; decreasing diss. 20956.2 by -10.0478swp new 24 <-> 15 old; decreasing diss. 20946.1 by -7.99457swp new 26 <-> 12 old; decreasing diss. 20938.1 by -3.0991swp new 44 <-> 22 old; decreasing diss. 20935 by -880.436swp new 45 <-> 4 old; decreasing diss. 20054.6 by -9.44638swp new 55 <-> 26 old; decreasing diss. 20045.1 by -1.77816swp new 57 <-> 24 old; decreasing diss. 20043.4 by -1.76138swp new 58 <-> 44 old; decreasing diss. 20041.6 by -178.122swp new 63 <-> 45 old; decreasing diss. 19863.5 by -0.34634swp new 71 <-> 57 old; decreasing diss. 19863.1 by -1.49747swp new 75 <-> 63 old; decreasing diss. 19861.6 by -1.31804swp new 76 <-> 71 old; decreasing diss. 19860.3 by -1.42789swp new 80 <-> 55 old; decreasing diss. 19858.9 by -5.29615swp new 81 <-> 75 old; decreasing diss. 19853.6 by -0.164308swp new 83 <-> 76 old; decreasing diss. 19853.4 by -0.0877432swp new 115 <-> 81 old; decreasing diss. 19853.3 by -0.303527swp new 171 <-> 58 old; decreasing diss. 19853 by -971.874swp new 185 <-> 115 old; decreasing diss. 18881.2 by -0.471238swp new 192 <-> 80 old; decreasing diss. 18880.7 by -0.294662swp new 257 <-> 185 old; decreasing diss. 18880.4 by -0.466733swp new 290 <-> 257 old; decreasing diss. 18879.9 by -0.105762swp new 309 <-> 83 old; decreasing diss. 18879.8 by -0.0395709swp new 419 <-> 192 old; decreasing diss. 18879.8 by -0.0439214swp new 425 <-> 309 old; decreasing diss. 18879.7 by -0.136105swp new 471 <-> 425 old; decreasing diss. 18879.6 by -0.244642swp new 501 <-> 171 old; decreasing diss. 18879.4 by -11830.7swp new 502 <-> 471 old; decreasing diss. 7048.64 by -273.113swp new 503 <-> 290 old; decreasing diss. 6775.52 by -813.133swp new 504 <-> 502 old; decreasing diss. 5962.39 by -20.8894swp new 507 <-> 504 old; decreasing diss. 5941.5 by -42.7153swp new 515 <-> 501 old; decreasing diss. 5898.79 by -0.453931swp new 523 <-> 515 old; decreasing diss. 5898.33 by -67.1248swp new 526 <-> 507 old; decreasing diss. 5831.21 by -0.673248swp new 527 <-> 526 old; decreasing diss. 5830.53 by -2.26904swp new 537 <-> 503 old; decreasing diss. 5828.26 by -3.1636swp new 542 <-> 527 old; decreasing diss. 5825.1 by -2.0623swp new 545 <-> 542 old; decreasing diss. 5823.04 by -17.9136swp new 547 <-> 523 old; decreasing diss. 5805.13 by -194.143swp new 573 <-> 547 old; decreasing diss. 5610.98 by -607.192swp new 576 <-> 545 old; decreasing diss. 5003.79 by -0.801911swp new 579 <-> 573 old; decreasing diss. 5002.99 by -347.734swp new 592 <-> 576 old; decreasing diss. 4655.26 by -0.997177swp new 604 <-> 592 old; decreasing diss. 4654.26 by -0.808458swp new 617 <-> 604 old; decreasing diss. 4653.45 by -1.02162swp new 813 <-> 537 old; decreasing diss. 4652.43 by -0.254896swp new 883 <-> 617 old; decreasing diss. 4652.17 by -1.83048swp new 955 <-> 813 old; decreasing diss. 4650.34 by -0.591944swp new 1015 <-> 883 old; decreasing diss. 4649.75 by -0.0303283swp new 1016 <-> 955 old; decreasing diss. 4649.72 by -0.343593swp new 1086 <-> 1016 old; decreasing diss. 4649.38 by -0.0942057swp new 1088 <-> 1015 old; decreasing diss. 4649.28 by -0.0747132swp new 1111 <-> 1086 old; decreasing diss. 4649.21 by -0.996659swp new 1131 <-> 1088 old; decreasing diss. 4648.21 by -0.773913swp new 1134 <-> 1111 old; decreasing diss. 4647.44 by -0.174449swp new 1151 <-> 1131 old; decreasing diss. 4647.26 by -0.319467swp new 1251 <-> 579 old; decreasing diss. 4646.94 by -1367.16swp new 1252 <-> 1251 old; decreasing diss. 3279.79 by -27.203swp new 1253 <-> 1151 old; decreasing diss. 3252.58 by -137.657swp new 1255 <-> 1252 old; decreasing diss. 3114.93 by -52.4651swp new 1257 <-> 1253 old; decreasing diss. 3062.46 by -42.3678swp new 1259 <-> 1255 old; decreasing diss. 3020.09 by -1.87135swp new 1266 <-> 1257 old; decreasing diss. 3018.22 by -90.6385swp new 1280 <-> 1259 old; decreasing diss. 2927.58 by -20.3614swp new 1283 <-> 1266 old; decreasing diss. 2907.22 by -272.98swp new 1288 <-> 1280 old; decreasing diss. 2634.24 by -1.69952swp new 1300 <-> 1288 old; decreasing diss. 2632.54 by -9.58469swp new 1325 <-> 1300 old; decreasing diss. 2622.96 by -7.37653swp new 1612 <-> 1283 old; decreasing diss. 2615.58 by -2.38886swp new 2001 <-> 1612 old; decreasing diss. 2613.19 by -788.545swp new 2089 <-> 2001 old; decreasing diss. 1824.65 by -3.28836swp new 2153 <-> 2089 old; decreasing diss. 1821.36 by -5.16445swp new 12 <-> 419 old; decreasing diss. 1816.19 by -28.3676swp new 15 <-> 12 old; decreasing diss. 1787.83 by -2.88573swp new 16 <-> 15 old; decreasing diss. 1784.94 by -3.50571swp new 33 <-> 16 old; decreasing diss. 1781.43 by -0.382726swp new 56 <-> 33 old; decreasing diss. 1781.05 by -0.660581swp new 70 <-> 56 old; decreasing diss. 1780.39 by -9.63432swp new 86 <-> 70 old; decreasing diss. 1770.76 by -2.56554swp new 123 <-> 86 old; decreasing diss. 1768.19 by -1.30247swp new 414 <-> 123 old; decreasing diss. 1766.89 by -0.130313swp new 507 <-> 1134 old; decreasing diss. 1766.76 by -1.67967swp new 509 <-> 507 old; decreasing diss. 1765.08 by -11.8255swp new 530 <-> 509 old; decreasing diss. 1753.25 by -9.54887swp new 542 <-> 530 old; decreasing diss. 1743.7 by -2.59694swp new 574 <-> 542 old; decreasing diss. 1741.11 by -3.50085swp new 913 <-> 574 old; decreasing diss. 1737.61 by -0.356354swp new 915 <-> 913 old; decreasing diss. 1737.25 by -0.471447swp new 1300 <-> 1325 old; decreasing diss. 1736.78 by -0.589135swp new 1421 <-> 1300 old; decreasing diss. 1736.19 by -2.94296swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415end{bswap()}, end{cstat()}Time user system elapsedTime 0.258 0.000 0.259> show6Ratios('6:orig' = st6/st0, '5:orig' = st5/st0, '4:orig' = st4/st0, '3:orig' = st3/st0, '2:orig' = st2/st0, '1:orig' = st1/st0)6:orig 5:orig 4:orig 3:orig 2:orig 1:origTime user.self 0.14939 0.19572 0.25999 0.29184 0.53619 0.78865Time sys.child NaN NaN NaN NaN NaN NaN>> ## only call element is not equal> stopifnot(all.equal(pamxst [-icall], pamxoncest [-icall]),+ all.equal(pamxoncest[-icall], pamxonce2st[-icall]),+ all.equal(pamxoncest[-icall], pamxonce3st[-icall]),+ all.equal(pamxoncest[-icall], pamxonce4st[-icall]),+ all.equal(pamxoncest[-icall], pamxonce5st[-icall]),+ all.equal(pamxoncest[-icall], pamxonce6st[-icall]))>>> ## Medoid bug --- MM: Fixed, well "0L+ hack", in my pam.q, on 2012-01-31> ## ----------> med0 <- (1:6)> st0 <- showSys.time(pamxst <- pam(x, 6, medoids = med0 , trace.lev=2))C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=0): medoids given; after build: medoids are 1 2 3 4 5 6swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582swp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531swp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848swp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054swp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256end{bswap()}, end{cstat()}Time user system elapsedTime 4.345 0.000 4.357> stopifnot(identical(med0, 1:6))> med0 <- (1:6)> st1 <- showSys.time(pamxst.1 <- pam(x, 6, medoids = med0 , pamonce=1, trace.lev=2))C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=1): medoids given; after build: medoids are 1 2 3 4 5 6swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582swp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531swp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848swp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054swp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256end{bswap()}, end{cstat()}Time user system elapsedTime 3.753 0.000 3.763> stopifnot(identical(med0, 1:6))> med0 <- (1:6)> st2 <- showSys.time(pamxst.2 <- pam(x, 6, medoids = med0 , pamonce=2, trace.lev=2))C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=2): medoids given; after build: medoids are 1 2 3 4 5 6swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582swp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531swp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848swp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054swp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256end{bswap()}, end{cstat()}Time user system elapsedTime 2.519 0.001 2.530> stopifnot(identical(med0, 1:6))> med0 <- (1:6)> st3 <- showSys.time(pamxst.3 <- pam(x, 6, medoids = med0 , pamonce=3, trace.lev=2))C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=3): medoids given; after build: medoids are 1 2 3 4 5 6swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582swp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531swp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848swp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054swp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256end{bswap()}, end{cstat()}Time user system elapsedTime 0.854 0.000 0.857> stopifnot(identical(med0, 1:6))> med0 <- (1:6)> st4 <- showSys.time(pamxst.4 <- pam(x, 6, medoids = med0 , pamonce=4, trace.lev=2))C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=4): medoids given; after build: medoids are 1 2 3 4 5 6swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582fswp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531fswp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848fswp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054fswp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256end{bswap()}, end{cstat()}Time user system elapsedTime 0.619 0.000 0.620> stopifnot(identical(med0, 1:6))> med0 <- (1:6)> st5 <- showSys.time(pamxst.5 <- pam(x, 6, medoids = med0 , pamonce=5, trace.lev=2))C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=5): medoids given; after build: medoids are 1 2 3 4 5 6swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582fswp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531fswp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848fswp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054fswp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256end{bswap()}, end{cstat()}Time user system elapsedTime 0.473 0.001 0.476> stopifnot(identical(med0, 1:6))> med0 <- (1:6)> st6 <- showSys.time(pamxst.6 <- pam(x, 6, medoids = med0 , pamonce=6, trace.lev=2))C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok]pam()'s bswap(*, s=15.7788, pamonce=6): medoids given; after build: medoids are 1 2 3 4 5 6swp new 7 <-> 6 old; decreasing diss. 20991.1 by -3.78677swp new 8 <-> 5 old; decreasing diss. 20987.4 by -25.0122swp new 9 <-> 2 old; decreasing diss. 20962.3 by -6.53934swp new 10 <-> 7 old; decreasing diss. 20955.8 by -0.133503swp new 11 <-> 9 old; decreasing diss. 20955.7 by -14.9294swp new 12 <-> 10 old; decreasing diss. 20940.7 by -2.35016swp new 13 <-> 12 old; decreasing diss. 20938.4 by -12.1267swp new 14 <-> 11 old; decreasing diss. 20926.3 by -2.99664swp new 15 <-> 13 old; decreasing diss. 20923.3 by -11.5871swp new 20 <-> 1 old; decreasing diss. 20911.7 by -0.0423835swp new 22 <-> 3 old; decreasing diss. 20911.6 by -8.76936swp new 23 <-> 20 old; decreasing diss. 20902.9 by -0.779336swp new 39 <-> 15 old; decreasing diss. 20902.1 by -0.285867swp new 44 <-> 4 old; decreasing diss. 20901.8 by -889.012swp new 45 <-> 14 old; decreasing diss. 20012.8 by -0.586001swp new 46 <-> 45 old; decreasing diss. 20012.2 by -1.1479swp new 57 <-> 39 old; decreasing diss. 20011.1 by -3.67274swp new 58 <-> 44 old; decreasing diss. 20007.4 by -189.36swp new 62 <-> 23 old; decreasing diss. 19818 by -0.626154swp new 66 <-> 46 old; decreasing diss. 19817.4 by -1.29082swp new 68 <-> 22 old; decreasing diss. 19816.1 by -0.580804swp new 75 <-> 62 old; decreasing diss. 19815.5 by -0.860328swp new 76 <-> 57 old; decreasing diss. 19814.7 by -1.97434swp new 171 <-> 58 old; decreasing diss. 19812.7 by -968.625swp new 185 <-> 75 old; decreasing diss. 18844.1 by -0.12972swp new 198 <-> 68 old; decreasing diss. 18843.9 by -0.533904swp new 204 <-> 198 old; decreasing diss. 18843.4 by -0.00928895swp new 218 <-> 185 old; decreasing diss. 18843.4 by -0.0287215swp new 280 <-> 204 old; decreasing diss. 18843.4 by -0.913559swp new 329 <-> 280 old; decreasing diss. 18842.5 by -0.101916swp new 361 <-> 8 old; decreasing diss. 18842.3 by -0.0966188swp new 402 <-> 361 old; decreasing diss. 18842.3 by -0.0394578swp new 501 <-> 171 old; decreasing diss. 18842.2 by -11833swp new 502 <-> 66 old; decreasing diss. 7009.24 by -309.206swp new 503 <-> 329 old; decreasing diss. 6700.03 by -887.644swp new 504 <-> 76 old; decreasing diss. 5812.39 by -28.554swp new 506 <-> 504 old; decreasing diss. 5783.83 by -14.2809swp new 507 <-> 506 old; decreasing diss. 5769.55 by -19.8604swp new 508 <-> 507 old; decreasing diss. 5749.69 by -7.88586swp new 515 <-> 501 old; decreasing diss. 5741.8 by -3.36477swp new 519 <-> 502 old; decreasing diss. 5738.44 by -1.16993swp new 523 <-> 515 old; decreasing diss. 5737.27 by -71.9147swp new 526 <-> 508 old; decreasing diss. 5665.35 by -1.56708swp new 533 <-> 526 old; decreasing diss. 5663.79 by -1.652swp new 537 <-> 519 old; decreasing diss. 5662.14 by -0.283073swp new 540 <-> 537 old; decreasing diss. 5661.85 by -2.35314swp new 545 <-> 533 old; decreasing diss. 5659.5 by -2.94604swp new 547 <-> 503 old; decreasing diss. 5656.55 by -221.229swp new 573 <-> 547 old; decreasing diss. 5435.32 by -574.75swp new 575 <-> 523 old; decreasing diss. 4860.57 by -17.1525swp new 579 <-> 573 old; decreasing diss. 4843.42 by -346.495swp new 593 <-> 575 old; decreasing diss. 4496.93 by -2.83188swp new 594 <-> 540 old; decreasing diss. 4494.1 by -0.50804swp new 618 <-> 545 old; decreasing diss. 4493.59 by -0.137577swp new 660 <-> 618 old; decreasing diss. 4493.45 by -4.45459swp new 663 <-> 593 old; decreasing diss. 4489 by -0.912682swp new 709 <-> 663 old; decreasing diss. 4488.08 by -1.44419swp new 848 <-> 594 old; decreasing diss. 4486.64 by -0.00137738swp new 991 <-> 709 old; decreasing diss. 4486.64 by -0.173764swp new 1242 <-> 660 old; decreasing diss. 4486.46 by -0.244432swp new 1251 <-> 579 old; decreasing diss. 4486.22 by -1369.29swp new 1252 <-> 402 old; decreasing diss. 3116.93 by -58.5165swp new 1253 <-> 1252 old; decreasing diss. 3058.42 by -169.451swp new 1255 <-> 1251 old; decreasing diss. 2888.97 by -30.8092swp new 1257 <-> 848 old; decreasing diss. 2858.16 by -70.3794swp new 1262 <-> 1255 old; decreasing diss. 2787.78 by -29.3154swp new 1266 <-> 1253 old; decreasing diss. 2758.46 by -64.8733swp new 1282 <-> 1262 old; decreasing diss. 2693.59 by -0.803303swp new 1283 <-> 1257 old; decreasing diss. 2692.79 by -238.314swp new 1284 <-> 1266 old; decreasing diss. 2454.47 by -6.79018swp new 1289 <-> 1284 old; decreasing diss. 2447.68 by -6.25715swp new 1291 <-> 1289 old; decreasing diss. 2441.42 by -1.33251swp new 1293 <-> 1291 old; decreasing diss. 2440.09 by -4.73682swp new 1299 <-> 1293 old; decreasing diss. 2435.35 by -5.10123swp new 1301 <-> 1282 old; decreasing diss. 2430.25 by -3.83834swp new 1322 <-> 1301 old; decreasing diss. 2426.41 by -1.61521swp new 1332 <-> 1322 old; decreasing diss. 2424.8 by -1.66893swp new 1335 <-> 1299 old; decreasing diss. 2423.13 by -9.28429swp new 1374 <-> 1332 old; decreasing diss. 2413.85 by -1.14706swp new 1469 <-> 1374 old; decreasing diss. 2412.7 by -0.0376604swp new 1583 <-> 1335 old; decreasing diss. 2412.66 by -0.0266074swp new 1612 <-> 1283 old; decreasing diss. 2412.64 by -1.78413swp new 2001 <-> 1612 old; decreasing diss. 2410.85 by -794.078swp new 2089 <-> 2001 old; decreasing diss. 1616.77 by -3.16676swp new 2153 <-> 2089 old; decreasing diss. 1613.61 by -5.2914swp new 12 <-> 218 old; decreasing diss. 1608.32 by -9.02144swp new 15 <-> 12 old; decreasing diss. 1599.29 by -2.88573swp new 16 <-> 15 old; decreasing diss. 1596.41 by -3.50571swp new 33 <-> 16 old; decreasing diss. 1592.9 by -0.382726swp new 56 <-> 33 old; decreasing diss. 1592.52 by -0.660581swp new 70 <-> 56 old; decreasing diss. 1591.86 by -9.63432swp new 86 <-> 70 old; decreasing diss. 1582.22 by -2.56554swp new 123 <-> 86 old; decreasing diss. 1579.66 by -1.30247swp new 414 <-> 123 old; decreasing diss. 1578.36 by -0.130313swp new 507 <-> 1242 old; decreasing diss. 1578.23 by -16.7114swp new 513 <-> 991 old; decreasing diss. 1561.51 by -2.15127swp new 518 <-> 507 old; decreasing diss. 1559.36 by -7.23052swp new 556 <-> 518 old; decreasing diss. 1552.13 by -1.79073swp new 622 <-> 513 old; decreasing diss. 1550.34 by -0.947204swp new 822 <-> 556 old; decreasing diss. 1549.4 by -0.320612swp new 926 <-> 622 old; decreasing diss. 1549.07 by -1.31521swp new 1106 <-> 926 old; decreasing diss. 1547.76 by -0.187491swp new 1124 <-> 822 old; decreasing diss. 1547.57 by -0.261824swp new 1194 <-> 1124 old; decreasing diss. 1547.31 by -0.0387596swp new 1256 <-> 1583 old; decreasing diss. 1547.27 by -1.04235swp new 1262 <-> 1469 old; decreasing diss. 1546.23 by -2.25214swp new 1429 <-> 1256 old; decreasing diss. 1543.98 by -0.359624swp new 1592 <-> 1429 old; decreasing diss. 1543.62 by -0.641983swp new 2286 <-> 2153 old; decreasing diss. 1542.98 by -0.109986swp new 2482 <-> 2286 old; decreasing diss. 1542.87 by -0.0744393end{bswap()}, end{cstat()}Time user system elapsedTime 0.282 0.001 0.284> stopifnot(identical(med0, 1:6))> stopifnot(all.equal(pamxst[-icall], pamxst.1 [-icall]),+ all.equal(pamxst[-icall], pamxst.2 [-icall]),+ all.equal(pamxst[-icall], pamxst.3 [-icall]),+ all.equal(pamxst[-icall], pamxst.4 [-icall]),+ all.equal(pamxst[-icall], pamxst.5 [-icall]))> # FasterPAM finds a better solution here, by chance> stopifnot(pamxst$objective >= pamxst.6$objective)>>> ## Last Line:> cat('Time elapsed: ', proc.time() - .proctime00,'\n')Time elapsed: 29.923 0.049 30.113 0 0>>> proc.time()user system elapsed30.026 0.082 30.241