normal_discrete (two dimensional) - fabiankindermann/ce-fortran GitHub Wiki

subroutine normal_discrete(n, x, prob, mu, sigma, rho)

Description:

This subroutine calculates the nodes and weights for an approximation of a two-dimensional normal distribution with mean

We can use these nodes and weights, for example, to calculate moments as

with

Input arguments:

  • integer :: n(2)
    An integer array of length 2 that indicates how many discretization points should be used in each of the two dimension of the normal distribution.

Output arguments:

  • real*8 :: x(:, :)
    A two-dimensional array into which the subroutine stores the nodes for the Gauss-Hermite approximation. Along the first dimension, this array needs to have the length n(1)*n(2). Along the second dimension, the size needs to be 2.
  • real*8 :: prob(:)
    A one-dimensional array into which the subroutine stores the weights or probabilities for the Gauss-Hermite approximation. Note that prob(:) needs to have exactly the the length n(1)*n(2).

Optional arguments:

  • real*8 :: mu(2)
    An array of length 2 that hands over the means and in each dimension. If not present, the mean is set to a value of 0.
  • real*8 :: sigma(2)
    An array of length 2 that hands over variances and in each dimension. If not present, the variance is set to a value of 1. Both variances must be greater than or equal to zero, otherwise the subroutine throws an error message.
  • real*8 :: rho
    The correlation coefficient of the two-dimensional normal distribution. If not present, the correlation coefficient is set to a value of 0.

References

  • Parts of this routine were copied and adapted from:
    • the Matlab codes provided in the CompEcon toolbox of Mario Miranda and Paul Fackler
  • For further reading refer to:
    • Miranda, M. & Fackler, P. (2002). Applied Computational Economics and Finance. Cambridge: MIT Press.
    • Stoer, J. & Bulirsch, R. (2002). Introduction to Numerical Analysis. New York: Springer Text in Applied Mathematics.
    • Press, W.H., Teukolsky, S.A., Vetterling, W.T. & Flannery, B.P. (1992). Numerical Recipes in Fortran 90: The Art of Parallel Scientific Computing, 2nd edition. Cambridge: Cambridge Univeristy Press.
  • This routine is used in the following programs:
    • prog10_04.f90
    • prog10_05.f90
    • prog10_06.f90
⚠️ **GitHub.com Fallback** ⚠️