odd handling of tensors by blsprice

1 回表示 (過去 30 日間)
Harry
Harry 2020 年 7 月 11 日
回答済み: Harry 2020 年 7 月 12 日
Hi
I am trying to investigate the shape of the scalar field of the Black Scholes option pricing formula.
In matalb to vary all 5 of the parameters rather than inputing a vector for each parameter, you have to do it by inputting a tesseract.
In the folowing code each tesseract is 12*12*12*12*12
Tess = ones(12,12,12,12,12);
StockPTess = Tess.*[1:12];
StockPTess = permute(StockPTess,[2,1,3,4,5]);
StrikePTess= Tess.*[1:12];
RateTess = Tess.*[0.05:0.05:0.6];
RateTess = permute(RateTess,[1,3,2,4,5]);
TimeTess = Tess.*[1:12];
TimeTess = permute(TimeTess,[1,3,4,2,5]);
VolTess = Tess.*[0.2:0.2:2.4];
VolTess = permute(VolTess,[1,3,4,5,2]);
Price = blsprice(StockPTess,StrikePTess,RateTess,TimeTess,VolTess);````
Instead of outputing a 12*12*12*12*12 matrix, this exports a 12*20736 matrix, from the help page i can see no indication of which entries in the matrix correspond to which element of the tesseract that I expected to get out.

採用された回答

Harry
Harry 2020 年 7 月 12 日
After testing this function I found that with the above set up:
columns 1-12 vary with strike price and the strike prices repeat from 13-24 etc
columns 1-12 all correspond to the same intrest rate as do 13-24 - this
pattern repeats until 144; and the cycle begins again at 145
columns 1-144 all correspond to the same duration of option; and so on
columns 1-1728 all correspond to the same volatility
this means that we can reshape the matrix to get the tesseract:
PriceTess =reshape(Price,[12,12,12,12,12]);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStochastic Differential Equation (SDE) Models についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by