# randou: Sample from an Ornstein-Uhlenbeck Process In ecosim: Toolbox for Aquatic Ecosystem Modeling

## Description

Samples from an Ornstein-Uhlenbeck process and optionally exponetiates the results. In contrast to most parameterizations, sd represents the asymptotic standard deviation rather than the coefficient in the drift term of the corresponding stochastic differential equation. As in `randnorm`, mean and sd are interpreted in original, not in log-transformed units to facilitate the characterization of uncertainty in original units.

## Usage

 `1` ```randou(mean=0,sd=1,tau=0.1,y0=NA,t=0:1000/1000,log=FALSE) ```

## Arguments

 `mean` Asymptotic mean of the process. `sd` Asymptotic standard deviation of the process. `tau` Correlation time of the process. `y0` Starting value of the process. If no value is given, the starting value will be drawn randomly from the asymptotic distribution. `t` Time points at which the process should be sampled. (Note: the value at t will be the starting value y0.) `log` Indicator whether the log of the variable should be an Ornstein-Uhlenbeck process (log=TRUE) rather than the variable itself. (Note: mean and sd are interpreted in original units also for log=TRUE.)

## Author(s)

Peter Reichert <peter.reichert@eawag.ch>

`randnorm`.
 ``` 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``` ```n <- 10000 tau <- 0.1 proc1 <- randou(mean=0,sd=1,tau=tau,y0= 0,t=0:n/n,log=FALSE) proc2 <- randou(mean=0,sd=1,tau=tau,y0= 1,t=0:n/n,log=FALSE) proc3 <- randou(mean=0,sd=1,tau=tau,y0=-1,t=0:n/n,log=FALSE) plot(proc1,xlim=c(0,1),ylim=c(-2.5,2.5),xlab="t",ylab="y",type="l") lines(proc2,col="red") lines(proc3,col="blue") abline(h=0) mean(proc1\$y) mean(proc2\$y) mean(proc3\$y) sd(proc1\$y) sd(proc2\$y) sd(proc3\$y) procl1 <- randou(mean=2,sd=2,tau=tau,y0=1,t=0:n/n,log=TRUE) procl2 <- randou(mean=2,sd=2,tau=tau,y0=2,t=0:n/n,log=TRUE) procl3 <- randou(mean=2,sd=2,tau=tau,y0=3,t=0:n/n,log=TRUE) plot(procl1,xlim=c(0,1),ylim=c(0,6),xlab="t",ylab="y",type="l") lines(procl2,col="red") lines(procl3,col="blue") mean(procl1\$y) mean(procl2\$y) mean(procl3\$y) sd(procl1\$y) sd(procl2\$y) sd(procl3\$y) ```