Derive Two Asset (Risky + Safe) and Choices/Outcomes Distribution (Analytical)
back to Fan's Dynamic Assets Repository Table of Content.
This uses ff_az_ds_vecsv, which works for single and multiple assets.
The function here works with both ff_akz_vf_vecsv as well as ff_wkz_vf_vecsv. Results are identical, but ff_wkz_vf_vecsv is significantly faster.
@include
@seealso
- derive distribution f(y'(y,z)) one asset loop: ff_az_ds
- derive distribution f(y'({x,y},z)) two assets loop: ff_akz_ds
- derive distribution f(y'({x,y},z, z')) two assets loop: ff_iwkz_ds
- derive distribution f(y'({y},z)) or f(y'({x,y},z)) vectorized: ff_az_ds_vec
- derive distribution f(y'({y},z, z')) or f(y'({x,y},z, z')) vectorized: ff_iwkz_ds_vec
- derive distribution f(y'({y},z)) or f(y'({x,y},z)) semi-analytical: ff_az_ds_vecsv
- derive distribution f(y'({y},z, z')) or f(y'({x,y},z, z')) semi-analytical: ff_iwkz_ds_vecsv
Contents
Set Parameters Main
Options for Distribution solutions
- it_subset = 5 is basic invoke quick test
- it_subset = 6 is invoke full test
- it_subset = 7 is profiling invoke
- it_subset = 8 is matlab publish
- it_subset = 9 is invoke operational (only final stats) and coh graph
close all; clear all; it_param_set = 8; st_akz_or_wkz = 'wkz';
Get Parameters
Note that akz and wkz share the smae funcgrid and default_param functions
% Set Parameters [param_map, support_map] = ffs_akz_set_default_param(it_param_set); support_map('bl_profile_dist') = false; % Call Grid Generator <https://fanwangecon.github.io/CodeDynaAsset/m_akz/paramfunc/html/ffs_akz_get_funcgrid.html ffs_akz_get_funcgrid> [armt_map, func_map] = ffs_akz_get_funcgrid(param_map, support_map); % 1 for override
Alternative 1: Solving the Dynamic Programming Problem (AKZ)
if (strcmp(st_akz_or_wkz, 'akz')) result_map = ff_akz_vf_vecsv(param_map, support_map, armt_map, func_map); end
Alternative 2: Solving the Dynamic Programming Problem (AWZ)
if (strcmp(st_akz_or_wkz, 'wkz')) result_map = ff_wkz_vf_vecsv(param_map, support_map, armt_map, func_map); end
Distribution Start Profiler and Timer
% Start Profiling if (it_param_set == 7) profile off; profile on; end % Start Timer if (support_map('bl_time')) tic; end % Get Profile name st_profile_name_main = support_map('st_profile_name_main');
Derive Distribution
% Call Distribution Program <https://fanwangecon.github.io/CodeDynaAsset/m_az/solve/html/ff_az_ds_vec.html ff_az_ds_vec>
result_map = ff_az_ds_vecsv(param_map, support_map, armt_map, func_map, result_map);
---------------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Summary Statistics for: cl_mt_pol_coh xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---------------------------------------- fl_choice_mean 6.6414 fl_choice_sd 3.2081 fl_choice_coefofvar 0.4830 fl_choice_prob_zero 0 fl_choice_prob_below_zero 0 fl_choice_prob_above_zero 1.0000 fl_choice_prob_max 4.0305e-35 tb_disc_cumu cl_mt_pol_cohDiscreteVal cl_mt_pol_cohDiscreteValProbMass CDF cumsumFrac ________________________ ________________________________ __________ __________ 0.44365 2.0787e-17 2.0787e-15 1.3886e-18 1.4896 -1.2355e-34 2.0787e-15 1.3886e-18 1.7324 5.888e-34 2.0787e-15 1.3886e-18 1.7861 1.302e-34 2.0787e-15 1.3886e-18 1.8481 9.5853e-35 2.0787e-15 1.3886e-18 1.9196 8.2243e-34 2.0787e-15 1.3886e-18 2.0021 3.0112e-33 2.0787e-15 1.3886e-18 2.0973 4.478e-33 2.0787e-15 1.3886e-18 2.207 2.6753e-33 2.0787e-15 1.3886e-18 2.3337 2.3579e-33 2.0787e-15 1.3886e-18 cl_mt_pol_cohDiscreteVal cl_mt_pol_cohDiscreteValProbMass CDF cumsumFrac ________________________ ________________________________ ___ __________ 57.254 -3.3621e-34 100 1 57.254 -9.1965e-35 100 1 57.262 -2.4901e-36 100 1 57.264 4.154e-34 100 1 57.269 6.6519e-35 100 1 57.271 -7.6799e-34 100 1 57.274 -4.6719e-35 100 1 57.275 1.9388e-34 100 1 57.277 3.6435e-34 100 1 57.277 4.0305e-35 100 1 tb_prob_drv percentiles cl_mt_pol_cohDiscreteValPercentileValues fracOfSumHeldBelowThisPercentile ___________ ________________________________________ ________________________________ 0.1 2.7703 0.00069849 1 2.9189 0.004584 5 3.3795 0.032016 10 3.9458 0.053826 15 4.1803 0.0984 20 4.3216 0.13587 25 4.4846 0.17815 35 4.6727 0.21852 50 5.557 0.33228 65 6.8355 0.47342 75 7.8814 0.58565 80 8.4891 0.65291 85 9.5307 0.71372 90 10.711 0.78852 95 13.177 0.8779 99 18.291 0.96896 99.9 24.692 0.99598 ---------------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Summary Statistics for: cl_mt_pol_a xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---------------------------------------- fl_choice_mean 0.3116 fl_choice_sd 1.1458 fl_choice_coefofvar 3.6771 fl_choice_prob_zero 0.8815 fl_choice_prob_below_zero 0 fl_choice_prob_above_zero 0.1185 fl_choice_prob_max -1.8289e-33 tb_disc_cumu cl_mt_pol_aDiscreteVal cl_mt_pol_aDiscreteValProbMass CDF cumsumFrac ______________________ ______________________________ ______ __________ 0 0.8815 88.15 0 1.0204 0.004604 88.61 0.015076 1.0204 0.031787 91.789 0.11916 1.0204 0.0025712 92.046 0.12758 1.0204 0.01136 93.182 0.16478 1.0204 2.2781e-05 93.184 0.16486 2.0408 5.4147e-05 93.19 0.16521 2.0408 0.0090059 94.09 0.22419 2.0408 0.0016921 94.259 0.23527 2.0408 0.015803 95.84 0.33877 cl_mt_pol_aDiscreteVal cl_mt_pol_aDiscreteValProbMass CDF cumsumFrac ______________________ ______________________________ ___ __________ 38.776 2.1975e-11 100 1 39.796 7.7418e-12 100 1 39.796 2.2868e-12 100 1 40.816 2.2593e-12 100 1 41.837 5.1186e-14 100 1 41.837 1.8082e-13 100 1 42.857 6.9386e-16 100 1 42.857 5.5886e-18 100 1 43.878 6.2975e-19 100 1 44.898 -1.8289e-33 100 1 tb_prob_drv percentiles cl_mt_pol_aDiscreteValPercentileValues fracOfSumHeldBelowThisPercentile ___________ ______________________________________ ________________________________ 0.1 0 0 1 0 0 5 0 0 10 0 0 15 0 0 20 0 0 25 0 0 35 0 0 50 0 0 65 0 0 75 0 0 80 0 0 85 0 0 90 1.0204 0.11916 95 2.0408 0.33877 99 6.1224 0.75309 99.9 11.224 0.95767 ---------------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Summary Statistics for: cl_mt_pol_k xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---------------------------------------- fl_choice_mean 4.5107 fl_choice_sd 2.2178 fl_choice_coefofvar 0.4917 fl_choice_prob_zero 2.0787e-17 fl_choice_prob_below_zero 0 fl_choice_prob_above_zero 1.0000 fl_choice_prob_max 2.7759e-07 tb_disc_cumu cl_mt_pol_kDiscreteVal cl_mt_pol_kDiscreteValProbMass CDF cumsumFrac ______________________ ______________________________ __________ __________ 0 2.0787e-17 2.0787e-15 0 1.0204 1.7394e-32 2.0787e-15 3.935e-33 2.0408 1.4185e-11 1.4185e-09 6.4178e-12 2.0408 8.1304e-05 0.0081304 3.6786e-05 2.0408 0.10713 10.721 0.048506 2.0408 0.00011561 10.733 0.048559 2.0408 1.5923e-07 10.733 0.048559 3.0612 0.00046316 10.779 0.048873 3.0612 0.33966 44.745 0.27939 3.0612 0.00084992 44.83 0.27996 cl_mt_pol_kDiscreteVal cl_mt_pol_kDiscreteValProbMass CDF cumsumFrac ______________________ ______________________________ ______ __________ 14.286 0.0011999 99.658 0.98758 15.306 0.0020765 99.865 0.99463 15.306 1.4854e-06 99.866 0.99463 16.327 0.00032962 99.898 0.99583 17.347 0.00029894 99.928 0.99698 18.367 0.0005054 99.979 0.99904 19.388 5.9342e-05 99.985 0.99929 20.408 4.6977e-05 99.99 0.9995 21.429 0.00010427 100 1 22.449 2.7759e-07 100 1 tb_prob_drv percentiles cl_mt_pol_kDiscreteValPercentileValues fracOfSumHeldBelowThisPercentile ___________ ______________________________________ ________________________________ 0.1 2.0408 0.048506 1 2.0408 0.048506 5 2.0408 0.048506 10 2.0408 0.048506 15 3.0612 0.27939 20 3.0612 0.27939 25 3.0612 0.27939 35 3.0612 0.27939 50 4.0816 0.42889 65 5.102 0.61601 75 5.102 0.61601 80 6.1224 0.74123 85 6.1224 0.74123 90 7.1429 0.80377 95 9.1837 0.91266 99 12.245 0.97174 99.9 17.347 0.99698 ---------------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Summary Statistics for: cl_mt_pol_c xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---------------------------------------- fl_choice_mean 1.8192 fl_choice_sd 0.5539 fl_choice_coefofvar 0.3045 fl_choice_prob_zero 0 fl_choice_prob_below_zero 0 fl_choice_prob_above_zero 1.0000 fl_choice_prob_max 4.0305e-35 tb_disc_cumu cl_mt_pol_cDiscreteVal cl_mt_pol_cDiscreteValProbMass CDF cumsumFrac ______________________ ______________________________ __________ __________ 0.44365 2.0787e-17 2.0787e-15 5.0695e-18 0.46916 -1.2355e-34 2.0787e-15 5.0695e-18 0.49467 -3.1576e-35 2.0787e-15 5.0695e-18 0.60745 1.7248e-33 2.0787e-15 5.0695e-18 0.71196 5.888e-34 2.0787e-15 5.0695e-18 0.72951 0.0016745 0.16745 0.00067151 0.73747 4.1415e-34 0.16745 0.00067151 0.7657 1.302e-34 0.16745 0.00067151 0.79121 -6.7513e-35 0.16745 0.00067151 0.79848 0.0030798 0.47543 0.0020233 cl_mt_pol_cDiscreteVal cl_mt_pol_cDiscreteValProbMass CDF cumsumFrac ______________________ ______________________________ ___ __________ 7.2536 -3.3621e-34 100 1 7.2536 -9.1965e-35 100 1 7.2624 -2.4901e-36 100 1 7.2636 4.154e-34 100 1 7.2692 6.6519e-35 100 1 7.2707 -7.6799e-34 100 1 7.274 -4.6719e-35 100 1 7.2752 1.9388e-34 100 1 7.2767 3.6435e-34 100 1 7.2772 4.0305e-35 100 1 tb_prob_drv percentiles cl_mt_pol_cDiscreteValPercentileValues fracOfSumHeldBelowThisPercentile ___________ ______________________________________ ________________________________ 0.1 0.72951 0.00067151 1 0.87804 0.0048445 5 0.99654 0.026976 10 1.1191 0.059063 15 1.2604 0.11006 20 1.3387 0.1374 25 1.4234 0.19492 35 1.5074 0.25414 50 1.7334 0.38022 65 2.0197 0.53374 75 2.162 0.64856 80 2.295 0.71757 85 2.3829 0.77205 90 2.597 0.8423 95 2.8274 0.9156 99 3.2736 0.98017 99.9 3.9464 0.99782 OriginalVariableNames cl_mt_pol_coh cl_mt_pol_a cl_mt_pol_k cl_mt_pol_c ______________________ _____________ ___________ ___________ ___________ 'mean' 6.6414 0.31162 4.5107 1.8192 'sd' 3.2081 1.1458 2.2178 0.55385 'coefofvar' 0.48304 3.6771 0.49168 0.30445 'min' 0.44365 0 0 0.44365 'max' 57.277 44.898 22.449 7.2772 'pYis0' 0 0.8815 2.0787e-17 0 'pYls0' 0 0 0 0 'pYgr0' 1 0.1185 1 1 'pYisMINY' 2.0787e-17 0.8815 2.0787e-17 2.0787e-17 'pYisMAXY' 4.0305e-35 -1.8289e-33 2.7759e-07 4.0305e-35 'p0_1' 2.7703 0 2.0408 0.72951 'p1' 2.9189 0 2.0408 0.87804 'p5' 3.3795 0 2.0408 0.99654 'p10' 3.9458 0 2.0408 1.1191 'p15' 4.1803 0 3.0612 1.2604 'p20' 4.3216 0 3.0612 1.3387 'p25' 4.4846 0 3.0612 1.4234 'p35' 4.6727 0 3.0612 1.5074 'p50' 5.557 0 4.0816 1.7334 'p65' 6.8355 0 5.102 2.0197 'p75' 7.8814 0 5.102 2.162 'p80' 8.4891 0 6.1224 2.295 'p85' 9.5307 0 6.1224 2.3829 'p90' 10.711 1.0204 7.1429 2.597 'p95' 13.177 2.0408 9.1837 2.8274 'p99' 18.291 6.1224 12.245 3.2736 'p99_9' 24.692 11.224 17.347 3.9464 'fl_cov_cl_mt_pol_coh' 10.292 2.268 6.545 1.4786 'fl_cor_cl_mt_pol_coh' 1 0.61698 0.91992 0.8322 'fl_cov_cl_mt_pol_a' 2.268 1.313 0.70477 0.25023 'fl_cor_cl_mt_pol_a' 0.61698 1 0.27733 0.3943 'fl_cov_cl_mt_pol_k' 6.545 0.70477 4.9186 0.92167 'fl_cor_cl_mt_pol_k' 0.91992 0.27733 1 0.75034 'fl_cov_cl_mt_pol_c' 1.4786 0.25023 0.92167 0.30675 'fl_cor_cl_mt_pol_c' 0.8322 0.3943 0.75034 1 'fracByP0_1' 0.00069849 0 0.048506 0.00067151 'fracByP1' 0.004584 0 0.048506 0.0048445 'fracByP5' 0.032016 0 0.048506 0.026976 'fracByP10' 0.053826 0 0.048506 0.059063 'fracByP15' 0.0984 0 0.27939 0.11006 'fracByP20' 0.13587 0 0.27939 0.1374 'fracByP25' 0.17815 0 0.27939 0.19492 'fracByP35' 0.21852 0 0.27939 0.25414 'fracByP50' 0.33228 0 0.42889 0.38022 'fracByP65' 0.47342 0 0.61601 0.53374 'fracByP75' 0.58565 0 0.61601 0.64856 'fracByP80' 0.65291 0 0.74123 0.71757 'fracByP85' 0.71372 0 0.74123 0.77205 'fracByP90' 0.78852 0.11916 0.80377 0.8423 'fracByP95' 0.8779 0.33877 0.91266 0.9156 'fracByP99' 0.96896 0.75309 0.97174 0.98017 'fracByP99_9' 0.99598 0.95767 0.99698 0.99782
End profiler and Timer
% End Timer if (support_map('bl_time')) toc; end % End Profiling if (it_param_set == 7) profile off profile viewer % append function name st_func_name = 'ff_akz_ds_vecsv'; support_map('st_profile_path') = [support_map('st_matimg_path_root') '/solve/profile/']; support_map('st_profile_name_main') = [st_func_name st_profile_name_main]; % support_map params_group = values(support_map, {'st_profile_path', ... 'st_profile_prefix', 'st_profile_name_main', 'st_profile_suffix'}); [st_profile_path, st_profile_prefix, st_profile_name_main, st_profile_suffix] = params_group{:}; % Save st_file_name = [st_profile_prefix st_profile_name_main st_profile_suffix]; profsave(profile('info'), strcat(st_profile_path, st_file_name)); end