# NOT RUN {
# The shape data has a structure of five clusters and a number of noise data points.
# }
# NOT RUN {
makecircle=function(N, seed){
n=0
x=matrix(NA, nrow=N, ncol=2)
while (n<N){
tmp=runif(2, min=0, max=1)*2-1
if (sum(tmp^2)<1) {
n=n+1
x[n,]=tmp
}
}
return(x)
}
makedata <- function(ns, seed) {
size=c(10,3,3,1,1)
mu=rbind(c(-0.3, -0.3), c(-0.55, 0.8), c(0.55, 0.8), c(0.9, 0), c(0.9, -0.6))
sd=rbind(c(0.7, 0.7), c(0.45, 0.2), c(0.45, 0.2), c(0.1, 0.1), c(0.1, 0.1))
x=NULL
for (i in 1:5){
tmp=makecircle(ns*size[i], seed+i)
tmp[,1]=tmp[,1]*sd[i,1]+mu[i,1]
tmp[,2]=tmp[,2]*sd[i,2]+mu[i,2]
x=rbind(x, tmp)
}
tmp=runif(floor(ns/3), min=0, max=1)/5-0.1
tmp=cbind(tmp, 0.8*rep(1, floor(ns/3)))
x=rbind(x, tmp)
x=rbind(x, matrix(1, nrow=2*ns, ncol=2)*2-1)
return(x)
}
shape1 <- makedata(250, 100)
dim(shape1)
plot(shape1)
X.supc=supc.random(shape1, r=0.5, t="dynamic", k = 500, implementation = "R")
plot(shape1, col=X.supc$cluster)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab