def simulateAR1(n,<EOL>beta,<EOL>sigma,<EOL>c,<EOL>burnin,<EOL>varNumCNR,<EOL>varNumTP,<EOL>):
<EOL>noise = np.empty((varNumCNR, varNumTP))<EOL>if burnin == <NUM_LIT:1>:<EOL><INDENT>burnin = <NUM_LIT:100><EOL>n = n + burnin<EOL><DEDENT>noiseTemp = c + sp.random.normal(<NUM_LIT:0>, <NUM_LIT:1>, n)<EOL>sims = np.zeros(n)<EOL>sims[<NUM_LIT:0>] = noiseTemp[<NUM_LIT:0>]<EOL>for i in range(<NUM_LIT:1>, n):<EOL><INDENT>sims[i] = beta*sims[i-<NUM_LIT:1>] + noiseTemp[i]<EOL><DEDENT>sims = sims[burnin:]<EOL>noise = sigma[:, np.newaxis]*sp.stats.mstats.zscore(sims)<EOL>return noise<EOL>
Simulates an AR(1) model using the parameters beta, c, and sigma.
Returns an array with length n

n := number of time points
beta := correlation weight
sigma := standard deviation of the noise, can be a vector
c := constant added to the noise, default 0

based on:
source1: https://github.com/ndronen/misc/blob/master/python/ar1.py
source2: http://stats.stackexchange.com/questions/22742/
         problem-simulating-ar2-process
source3: https://kurtverstegen.wordpress.com/2013/12/07/simulation/