1 | sdwe(m, K = 3)
|
m |
|
K |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (m, K = 3)
{
m = elimna(m)
pd = 1/(1 + zdepth(m))
MPD = median(pd)
flag = (pd < MPD)
W = rep(1, rep(length(pd)))
W[flag] = (exp(0 - K * (1 - pd[flag]/MPD)^2) - exp(0 - K))/(1 -
exp(0 - K))
bot = sum(W)
temp = m
for (i in 1:length(pd)) temp[i, ] = W[i] * m[i, ]
val = apply(temp, 2, sum)/bot
dif = m
for (i in 1:length(pd)) dif[i, ] = m[i, ] - val
V = matrix(0, ncol(m), ncol(m))
for (i in 1:length(pd)) V = V + W[i] * (as.matrix(dif[i,
]) %*% t(as.matrix(dif[i, ])))
V = V/bot
list(center = val, cov = V)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.