# Clustering
# Author:  Isabel Darcy 
# Date:  Feb 5, 2017

a <- sort(runif(30, 0,3))
sa <-sin(a)
plot(sa)
b <- sort(runif(25, 0,3))
sb <-sin(b)
plot(sb)
c <- sort(runif(20, 0,3))
sc <- b^2
plot(sc)

plot(ecdf(sa))
plot(ecdf(sb), add=TRUE, col="red")
plot(ecdf(sc), add=TRUE, col="blue")

plot(ecdf(sc))
plot(ecdf(sb), add=TRUE, col="red")
plot(ecdf(sa), add=TRUE, col="blue")

ks.test(sa, sb)
ks.test(sc, sb)
ks.test(sa, sc)

###############################################################
##### Create dendograms for a variety of data sets        #####
###############################################################

## Create dendograms for a variety of data sets including some of the data
## sets that you worked with earlier this week.  Also create dendograms for 
## data sets containing circles, noise, circles plus noise. See below for 
## how to create these data sets.

## Recall that you can determine how to use a command using ? or help
mydata <- Noise
mydata <- c(0,7,2, 10, 6)
d <- dist(as.matrix(mydata))   # find distance matrix for dataset
hc <- hclust(d, method = "single")                 # apply hierarchical clustering 
plot(hc)                        # plot the dendrogram
d
?hclust
plot(as.dendrogram(hclust(dist(data))))
k <-3
#x <- identify(hclust(dist(data)))

?identify
hc