Description Usage Arguments Value Examples
Write a function to compute a Monte Carlo estimate of the Beta(3, 3) cdf
Compare the estimates with the values returned by the pbeta function in R
1 | MCbeta(x)
|
x |
the number of points between 0 and 1 |
the first value is Monte Carlo estimate;the second value is the pbeta estimate;the third value is the error of
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
x_seq <- seq(.1,.9,by=.1)
F_seq <- numeric(length(x_seq))
P_seq <- numeric(length(x_seq))
for (i in 1:length(x_seq)) {
F_seq[i] <- F(x_seq[i]) # using the F function to estimate the probability
P_seq[i] <- pbeta(x_seq[i],3,3) # using the pbeta function in R to estimate the probability
}
print(round(rbind(x_seq, F_seq, P_seq), 3))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.