1 | kssig(m, n, val)
|
m |
|
n |
|
val |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ##---- 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, n, val)
{
cmat <- matrix(0, m + 1, n + 1)
umat <- matrix(0, m + 1, n + 1)
for (i in 0:m) {
for (j in 0:n) cmat[i + 1, j + 1] <- abs(i/m - j/n)
}
cmat <- ifelse(cmat <= val, 1, 0)
for (i in 0:m) {
for (j in 0:n) if (i * j == 0)
umat[i + 1, j + 1] <- cmat[i + 1, j + 1]
else umat[i + 1, j + 1] <- cmat[i + 1, j + 1] * (umat[i +
1, j] + umat[i, j + 1])
}
term <- lgamma(m + n + 1) - lgamma(m + 1) - lgamma(n + 1)
kssig <- 1 - umat[m + 1, n + 1]/exp(term)
kssig
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.