In this appendix MATLAB scripts for the moment-inversion algorithms discussed in Chapter 3 are reported.
A.1 Univariate quadrature
A.1.1 The PD algorithm
Below a MATLAB script calculating the nodes xi and the weights w of a quadrature approximation starting from the moments of the NDF is reported. The script uses the vector m containing the N moments to calculate the matrix P, the vector zeta, and the coefficients of the Jacobi matrix jacobi. The eigenvalues and eigenvectors (eval, evect) are then calculated by using the MATLAB function eig, and eventually nodes and weights are calculated and returned.