1 | dev.rej(X)
|
X |
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 27 28 | ##---- 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 (X)
{
S <- pi * exp(-pi^2 * X/8)/2
n <- 0
Y <- runif(1, 0, 1) * S
repeat {
n <- n + 1
S <- S - (-1)^n * pi * (n + 1/2) * exp(-(n + 1/2)^2 *
pi^2 * X/2)
if (Y < S) {
Acc <- 1
break
}
n <- n + 1
S <- S + (-1)^n * pi * (n + 1/2) * exp(-(n + 1/2)^2 *
pi^2 * X/2)
if (Y > S) {
Acc <- 0
break
}
}
list(Acc = Acc, S = S, n = n, Y = Y, X = X)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.