# Set seed for reproducibility
set.seed(0)
# Generate a dataset of 500 samples with 2 features following a uniform distribution
data_uniform <- data.frame(
Feature1 = runif(500, min = 0, max = 1),
Feature2 = runif(500, min = 0, max = 1)
)
head(data_uniform)
# Compute the distance matrix
dist_matrix <- dist(data_uniform)
# Apply hierarchical clustering using the Ward's method
hc <- hclust(dist_matrix, method = "ward.D2")
# Plot the dendrogram
plot(hc, main = "Hierarchical Clustering Dendrogram (Uniform Distribution)",
xlab = "Sample Index", ylab = "Height", sub = "", cex = 0.6)
