THEFUNCTION1D: THEFUNCTION1D

Description Usage Arguments Value Examples

Description

This function produces a random sample for any given continuous, finite probability distribution.

Usage

1
THEFUNCTION1D(n = 1, pdf, lower_bound = 0, upper_bound = 1, C = 1)

Arguments

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.

Value

Random sample in the form of a numeric vector.

Examples

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.

elliottcp/Probability-Semester-Project documentation built on May 24, 2019, 4:08 p.m.