```
require(GridOnClusters)
#> Loading required package: GridOnClusters
= rnorm(500)
x = sin(x)+rnorm(500, sd = 0)
y = cos(x)+rnorm(500, sd = 0)
z = cbind(x, y, z)
data = 10
ks
= discretize.jointly(data, k=ks, cluster_method = "Ball+BIC",
res grid_method = "Sort+split", min_level = 1)
plot(res)
= discretize.jointly(data, k=ks, cluster_method = "kmeans+silhouette",
res grid_method = "Sort+split", min_level = 1)
plot(res)
```

```
= rnorm(100)
x = log1p(abs(x))
y = ifelse(x >= -0.5 & x <= 0.5, 0, 1) + rnorm(100, 0, 0.1)
z = cbind(x, y, z)
data = c(2:5)
ks
= discretize.jointly(data, k=ks, cluster_method = "Ball+BIC",
res grid_method = "Sort+split", min_level = 1)
plot(res)
= discretize.jointly(data, k=ks, cluster_method = "kmeans+silhouette",
res grid_method = "Sort+split", min_level = 1)
plot(res)
```

```
# using a clustering method other than kmeans+silhouette
= rnorm(100)
x = log1p(abs(x))
y = sin(x)
z = cbind(x, y, z)
data
# pre-cluster the data using partition around medoids (PAM)
= cluster::pam(x=data, diss = FALSE, metric = "euclidean", k = 4)$clustering
cluster_label
= discretize.jointly(data, cluster_label = cluster_label,
res grid_method = "Sort+split", min_level = 1)
plot(res, main="Original data\nPAM clustering",
main.table="Discretized data\nPAM & Sort+split")
```

```
= 2:20
ks = 40*10
n = 60*4
sd
=rnorm(2*n, sd=sd)
x=rnorm(2*n, sd=sd)
y=c(x,rnorm(2*n, sd=sd/3))
x=c(y,rnorm(2*n, sd=sd/3)+200)
y
= cbind(x, y)
data
= discretize.jointly(data, k=ks, cluster_method = "Ball+BIC",
res grid_method = "Sort+split", min_level = 1)
plot(res)
= discretize.jointly(data, k=ks, cluster_method = "kmeans+silhouette",
res grid_method = "Sort+split", min_level = 1)
plot(res)
```

```
<- 50*8
n <- 2:20
ks
<- matrix(
X.C1 c(rnorm(n, 5, sd=2),
rnorm(n, 0, sd=40)),
ncol = 2, byrow = FALSE
)<- matrix(
X.C2 c(rnorm(n, 70, sd=1),
rnorm(n, 0, sd=1)),
ncol = 2, byrow = FALSE
)
<- matrix(
X.C3 c(rnorm(n, 150, sd=30),
rnorm(n, 0, sd=30)),
ncol = 2, byrow = FALSE
)
= rbind(X.C1, X.C3)
data
= discretize.jointly(data, k=ks, cluster_method = "Ball+BIC",
res grid_method = "Sort+split", min_level = 1)
plot(res)
= discretize.jointly(data, k=ks, cluster_method = "kmeans+silhouette",
res grid_method = "Sort+split", min_level = 1)
plot(res)
```