Description Usage Arguments Details Value Examples
This function implements one and two variable rejection sampling to find probabilities.
1 |
f |
The pdf you wish to use to find the probability of. For 2D probability density functions, the argument must be a vector of the two parameters of the pdf. |
q |
The value you want the samples to be less than. For 2D, the value you want your function g to be less than. |
g |
The function of random variables x and y for 2D that you wish to find the probability associated with. |
This function is in an implimentation of a distribution function for single and two variable pdfs using the samplr
rejection sampler.
For one dimensional variables, this function uses samplr
to find P(X < q)
.
For two dimensional random variables, this function uses samplr
to find P(g(X,Y) < q)
, where X
and Y
are found using samplr(f, 10000, twod = TRUE)
.
A number between 0 and 1 associated with the distribution function.
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 29 30 31 | One dimensional
f <- function(x) {
ifelse(0 < x & x < 1, 2*x, 0)
}
psamplr(f,.5)
f <- function(x) {
ifelse(0 < x & x < 2, 1/2*x, 0)
}
psamplr(f,1)
f <- function(x) {
ifelse(0 < x & x < 6.2832, 1/2/pi*(sin(x) + 1), 0)
}
psamplr(f,pi)
Two dimensional
f <- function(z) {
x <- z[1]
y <- z[2]
ifelse(0 <= x & x <= 1 & 0 <= y & y <= 1, x + y, 0)
}
g <- function(z) {
x <- z[1]
y <- z[2]
2*x + y
}
psamplr(f,1,f)
psamplr(f,2,g)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.