Description Usage Arguments Value Examples
This function produces a random sample for any given continuous, finite probability distribution.
1 | THEFUNCTION1D(n = 1, pdf, lower_bound = 0, upper_bound = 1, C = 1)
|
n |
The desired number of samples from the given distribution. |
pdf |
A probability density function. The user is responsible for ensuring it is valid. |
lower_bound |
The lower limit of possible sample values. |
upper_bound |
The upper limit of possible sample values. |
C |
A real number greater than all possible values of the pdf. |
Random sample in the form of a numeric vector.
1 2 3 4 5 6 7 8 9 | pdf <- function(x) {dnorm(x,0,1)}
sample <- THEFUNCTION1D(pdf, n = 100000, lower_bound = -5, upper_bound = 5, C = 0.4)
pdf <- function(x) {dunif(x,-10,10)}
sample <- THEFUNCTION1D(pdf, n = 200, lower_bound = -10, upper_bound = 10, C = 0.06)
If the function produces an error, check for faulty parameters,
such as n less than 1, non-numeric lower_bound, non-numeric
upper_bound, non-numeric C, or lower_bound greater than the upper_bound.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.