%% scriptExp01.m - compare grids and border effects
clear all
scriptSetData;
numScenarios = 20;
[values, retProbs] = MakeScenariosQ(numScenarios,mu,sigma);
retScenarios = values - 1; 
% use power utility
delta = 3;
utilFun = @(x) x.^(1-delta)/(1-delta);
% grid and time instants for plotting splines
gridW = linspace(1,200,100);
timeList = [9,6,3,1];
%% set up discretization for DP: WealthMax 200, numPoints 30
Wmin = 1; Wmax = 200; numPoints = 30;
wealthValues = linspace(Wmin,Wmax,numPoints);
wealthGrid = repmat({wealthValues(:)}, timeHorizon, 1);
% Learn DP policy (cubic)
splineList_1 = FindDPPolicy(utilFun, gamma, wealthGrid, incomeValues, ...
    transMatrix, retScenarios, retProbs, riskFree);
figure(1); PlotDPSplines(splineList_1, gridW, timeList);
%% set up discretization for DP: WealthMax 200, numPoints 30 + 2 sentinels
Wmin = 1; Wmax = 200; numPoints = 30;
wealthValues = [linspace(Wmin,Wmax,numPoints), 300, 500];
wealthGrid = repmat({wealthValues(:)}, timeHorizon, 1);
% Learn DP policy (cubic)
splineList_2 = FindDPPolicy(utilFun, gamma, wealthGrid, incomeValues, ...
    transMatrix, retScenarios, retProbs, riskFree);
figure(2); PlotDPSplines(splineList_2, gridW, timeList);

