% Copyright (c) 2001-2009 by Ales Cerny %************************************************************************% % chapter11sect9c.m - supplementary program to % % Ales Cerny (2009) Mathematical Techniques in Finance (2nd ed.) % % Princeton University Press http://press.princeton.edu/titles/9079.html % %************************************************************************% % This code is provided 'as-is', without any express or implied warranty. % % Permission is granted to anyone to use this code for any purpose, % subject to the following restrictions: % % 1. The origin of this code must not be misrepresented; you must not % claim that you wrote the original code. % 2. Modified code versions must be plainly marked as such, and must not % be misrepresented as being the original code. % 3. This notice may not be removed from any source distribution. % NOTICE TO STUDENTS: To avoid accusations of plagiarism, if you use this % code or its modifications in assessed work you should prepend it with a % note stating: % "This is the original/modified version of the code chapter11sect9c.m by % Ales Cerny (2009), Mathematical Techniques in Finance (2nd ed.), % Princeton University Press. The original version is available from % http://www.martingales.info/mtfweb2". % A similar acknowledgement should appear prominently inside your written % report. clear; clc; data= [-0.02918 0.06140 -0.00259722; 0.08962 -0.1523 0.01854934; 0.15155 0.10073 0.13588459; -0.12491 -0.09442 -0.11532253; -0.04639 0.01230 -0.02901336; 0.05284 0.03451 0.04719985; 0.03719 0.03337 0.03586913; -0.00900 0.10135 0.02323722; -0.18073 -0.09395 -0.15441354; 0.05896 -0.00299 0.04056263]; sigY=data'* data; [Q,R] = qr(data,0); idx = rank(R); disp(' '); disp(' covariance matrix sigY '); disp(' '); disp(sigY); disp(' '); disp(' '); disp('lower triangular matrix from QR decomposition of data'); disp(' '); disp(R(1:idx,:)'); disp(' '); disp(' '); disp(' R * R'' '); disp(' '); disp(R'*R); disp(' ');