Main Content

getScenarios

Obtain scenarios from portfolio object

Description

Use the getScenarios function with a PortfolioCVaR or PortfolioMAD objects to obtain scenarios.

For details on the workflows, see PortfolioCVaR Object Workflow, and PortfolioMAD Object Workflow.

example

Y = getScenarios(obj) obtains scenarios for PortfolioCVaR or PortfolioMAD objects.

Examples

collapse all

For a given PortfolioCVaR object p, display the defined scenarios.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];

m = m/12;
C = C/12;

rng(11);

AssetScenarios = mvnrnd(m, C, 10);

p = PortfolioCVaR;
p = setScenarios(p, AssetScenarios);
p = setDefaultConstraints(p);
p = setProbabilityLevel(p, 0.95);

Y = getScenarios(p)
Y = 10×4

   -0.0056    0.0440    0.1186    0.0488
   -0.0368   -0.0753    0.0087    0.1124
    0.0025    0.0856    0.0484    0.1404
    0.0318    0.0826    0.0377    0.0404
    0.0013   -0.0561   -0.1466   -0.0621
    0.0035    0.0310   -0.0183    0.1225
   -0.0519   -0.1634   -0.0526    0.1528
    0.0029   -0.1163   -0.0627   -0.0760
    0.0192   -0.0182   -0.1243   -0.1346
    0.0440    0.0189    0.0098    0.0821

The function rng(seed) resets the random number generator to produce the documented results. It is not necessary to reset the random number generator to simulate scenarios.

For a given PortfolioMAD object p, display the defined scenarios.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

rng(11);

AssetScenarios = mvnrnd(m, C, 10);

p = PortfolioMAD;
p = setScenarios(p, AssetScenarios);
p = setDefaultConstraints(p);

Y = getScenarios(p)
Y = 10×4

   -0.0056    0.0440    0.1186    0.0488
   -0.0368   -0.0753    0.0087    0.1124
    0.0025    0.0856    0.0484    0.1404
    0.0318    0.0826    0.0377    0.0404
    0.0013   -0.0561   -0.1466   -0.0621
    0.0035    0.0310   -0.0183    0.1225
   -0.0519   -0.1634   -0.0526    0.1528
    0.0029   -0.1163   -0.0627   -0.0760
    0.0192   -0.0182   -0.1243   -0.1346
    0.0440    0.0189    0.0098    0.0821

The function rng(seed) resets the random number generator to produce the documented results. It is not necessary to reset the random number generator to simulate scenarios.

Input Arguments

collapse all

Object for portfolio, specified using a PortfolioCVaR or PortfolioMAD object.

For more information on creating a PortfolioCVaR or PortfolioMAD object, see

Data Types: object

Output Arguments

collapse all

Scenarios matrix, returned as a NumScenarios-by-NumAssets matrix for a PortfolioCVaR or PortfolioMAD object.

Tips

You can also use dot notation to obtain scenarios from a PortfolioCVaR or PortfolioMAD object.

Y = obj.getScenarios;

Version History

Introduced in R2012b