-
Notifications
You must be signed in to change notification settings - Fork 46
simulate_AR
Fabian Kindermann edited this page Apr 2, 2021
·
5 revisions
subroutine simulate_AR(pi, shocks, fixed)
Simulates a time series of realizations from a discretized AR(1) process. Before being able to apply this simulation procedure, the process needs to be discretized into nodes and a transition matrix using the subroutine discretize_AR from the toolbox. The subroutine returns a series of indices that was draw according to the transition matrix . It thereby assumes that . To simulate the actual shock values, we just set .
-
integer :: pi(:, :)
The transition matrix calculated with the subroutine discretize_AR . Note that this matrix needs to be a square matrix, the rows of which sum up to 1.
-
integer :: shocks(:)
The subroutine stores the realizations of the time series in the one-dimensional arrayshocks
. Note that the output values are of integer type, as they denote the indices of the respective discretization nodes.
-
logical :: fixed
If a logical variablefixed
is passed to the subroutine that takes the value.true.
, the subroutine uses a fixed random seed. As a result, the sequence of random numbers drawn by the subroutine will always be the same every time your program is restarted. Iffixed
is not present or takes a value of.false.
, then the random seed is initialized at some arbitrary value that depends on the time and date at which you started your program. Hence, the series of random numbers drawn by this subroutine will be different every time your program is restarted.
- Parts of this routine were copied and adapted from:
- The GNU gfortran compiler documentation for the initialization of the seed of the random number generator.
- For further reading refer to:
- Toral, R. & Colet, P. (2014). Stochastic Numerical Methods: An Introduction for Students and Scientists. Weinheim: Wiley.
- This routine is used in the following programs:
prog09_03.f90
prog09_04.f90
prog09_05.f90
prog09_06.f90
prog09_07.f90
prog09_08.f90