1 | qrq(s, a)
|
s |
|
a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ##---- 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 (s, a)
{
if (min(a) < 0 | max(a) > 1)
stop("alphas out of range [0,1]")
r <- s$sol[1, ]
q <- s$sol[2, ]
q <- c(q[1], q)
J <- length(r)
r <- c(0, (r[1:J - 1] + r[2:J])/2, 1)
u <- rep(0, length(a))
for (k in 1:length(a)) {
i <- sum(r < a[k])
w <- (a[k] - r[i])/(r[i + 1] - r[i])
u[k] <- w * q[i + 1] + (1 - w) * q[i]
}
u
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.