boxMuller: Computes Box Muller Transformation

Description Usage Arguments Details Value Examples

View source: R/boxMuller.R

Description

takes a desired value for n and returns n samples from the standard normal distribution using Box Muller Transformation

Usage

1

Arguments

n

number of sample estimates from the normal distribution

Details

computes n samples using the Box Muller transformation to estimate samples from a normal distribution. Uses the following two formulas:

x1 = sqrt(-2*log(u1)) * (cos(2*pi*u2))
x2 = sqrt(-2*log(u1)) * (sin(2*pi*u2))

Value

a vector of doubles of size n sampled from the normal standard distribution N(0,1)

Examples

1
2
3
4
normal_estimate <- boxMuller(500)
#verify that mu and std is approximately 0 and 1
mean(normal_estimate)
sd(normal_estimate)

frankchien/bmi585flc documentation built on Dec. 20, 2021, 8:51 a.m.