From 95c2fdf28fdbe67e92c26ab907048b5151927d89 Mon Sep 17 00:00:00 2001 From: dcaff Date: Tue, 23 Apr 2013 20:24:14 -0600 Subject: [PATCH 1/2] test, added periods --- CompPack/CompPack.Rproj | 13 +++++++++++++ CompPack/debug.log | 0 R/pois.proc.R | 2 +- R/rand.unif.R | 6 +++--- debug.log | 0 5 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 CompPack/CompPack.Rproj create mode 100644 CompPack/debug.log create mode 100644 debug.log diff --git a/CompPack/CompPack.Rproj b/CompPack/CompPack.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/CompPack/CompPack.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/CompPack/debug.log b/CompPack/debug.log new file mode 100644 index 0000000..e69de29 diff --git a/R/pois.proc.R b/R/pois.proc.R index b946f40..9b84070 100644 --- a/R/pois.proc.R +++ b/R/pois.proc.R @@ -1,6 +1,6 @@ #' Generate a Poisson Process #' -#' @param end the end time. +#' @param end the end time desired. #' @param rate the rate of occurrence. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} diff --git a/R/rand.unif.R b/R/rand.unif.R index 5fc1b88..11ccfa7 100644 --- a/R/rand.unif.R +++ b/R/rand.unif.R @@ -1,8 +1,8 @@ #' Generate Random Uniform Variables #' -#' @param n Number of observations -#' @param min lower limit of the distribution -#' @param max upper limit of the distribution +#' @param n Number of observations. +#' @param min lower limit of the distribution. +#' @param max upper limit of the distribution. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' diff --git a/debug.log b/debug.log new file mode 100644 index 0000000..e69de29 From e19b89239dc79985728f3aa0978715cbe6365b0e Mon Sep 17 00:00:00 2001 From: dcaff Date: Wed, 24 Apr 2013 12:52:24 -0600 Subject: [PATCH 2/2] Polar random normal --- R/rand.norm.R | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/R/rand.norm.R b/R/rand.norm.R index 46920c1..0d5b4f7 100644 --- a/R/rand.norm.R +++ b/R/rand.norm.R @@ -1,13 +1,27 @@ -#' Generate Random Normal Variables +#' Generate A Random Normal Variable #' -#' @param n Number of observations -#' @param mean vector of means -#' @param sd vector of standard deviations +#' @description A method for generating a random normal variable based upon the polar method. +#' @param mu mean of a normal distribution +#' @param sigma variance of a normal distribution #' -#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} +#' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} #' #' @export -rand.norm<-function(n, mean, sd){ - qnorm( replicate( n, wich.hill() ) )*sd + mean +function(mu,sig) +{ + + u<-(2*wichmannhill()-1) + v<-(2*wichmannhill()-1) + + s<-u^2+v^2 + + while(s==0||s>=1) + { + u<-(2*wichmannhill()-1) + v<-(2*wichmannhill()-1) + + s<-u^2+v^2 + } + sig*sqrt(-2*log(s)/s)*u + mu }