# NOT RUN {
# Load a 2-dimensional data set.
data(clusters2d)
#
# Set seed for reproduction.
set.seed(5)
#
# Projection median approximated by Monte Carlo Integration.
PmedMCInt(clusters2d, nprojs = 30000)
# [1] 4.3369501 -0.1578591
#
#
# Projection median approximated by the trapezoidal rule.
PmedTrapz(clusters2d,no.subinterval=180)
# [1] 4.1556553 -0.3566614
#
#
# Yamm.
set.seed(5)
yamm(clusters2d,nprojs = 2500,reltol=1e-3,doabs=1,full.results=FALSE)
# [1] 4.3871582 -0.1070497
#
#
# Plot 2-D medians
# Remove the outliers of the dataset.
cluster_without_outlier <- clusters2d[c(1:101),]
myxvec <- c(min(cluster_without_outlier[,1]),
max(cluster_without_outlier[,1]))
myyvec <- c(min(cluster_without_outlier[,2]),
max(cluster_without_outlier[,2]))
#
# Plot the figure.
set.seed(5)
Plot2dMedian(clusters2d, myxvec, myyvec, yamm.nprojs = 2000,
PmedMCInt.nprojs = 20000, no.subinterval = 36,
opt.method = "BFGS", xlab = "Component1",
ylab = "Component2")
# }
Run the code above in your browser using DataLab