Need some help looping(iteration in french) for a standard deviation with B&S formula
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I am looking to get a standard deviation to use in Leland's model so i use the Black and Scholes formula which i inverse in order to input a starting standard deviation to get asset value as an output. Then with this new serie of value i calculate another standard deviation and i keep going until i find the differences between the two last standard deviation to be near zero. I already used this kind of formula in class for a simpler exemple then what i am trying to do now though but it worked, trying to use it now i get error messages which i dont really understand. I'l post my formula and the errors it gives me in hope someone knows what it is and how i can get it fixed.
formula :
Valeur_Actifs(i,1) = fzero(@(v)((v*normcdf(((log(v/M)+(r+(Volatilite_Iterations(1,c)^2/2))*T)/(Volatilite_Iterations(1,c)*sqrt(T))),0,1)-((M*exp(-r*T))*normcdf(((log(v/M)+(r-(Volatilite_Iterations(1,c)^2/2))*T)/(Volatilite_Iterations(1,c)*sqrt(T))),0,1))))-S,v0);
Errors messages :
? ?? Undefined function or method 'erfc' for input arguments of type 'double' and attributes 'full scalar complex'.
Error in ==> normcdf at 68
p = 0.5 * erfc(-z ./ sqrt(2));
Error in ==>
@(v)((v*normcdf(((log(v/M)+(r+(Volatilite_Iterations(1,c)^2/2))*T)/(Volatilite_Iterations(1,c)*sqrt(T))),0,1)-((M*exp(-r*T))*normcdf(((log(v/M)+(r-(Volatilite_Iterations(1,c)^2/2))*T)/(Volatilite_Iterations(1,c)*sqrt(T))),0,1))))-v0
Error in ==> fzero at 369
a = x - dx; fa = FunFcn(a,varargin{:});
I get allthose message but it seems some returns me to some error about the normal distribution which i used as it is in matlab already
Sorry if i the message isnt so clear english is my second language
Thanks in advance
If some other part of my code could help u awnser my question (maybe when i define the variables i used in the formula) dont hesitate to ask for it i would really appreciate if someone was able to help me
Answers (1)
Walter Roberson
on 2 Aug 2012
0 votes
normcdf() is defined in MATLAB in terms of erfc(), but erfc() in MATLAB does not appear to support complex inputs.
For erfc() with complex inputs, please see http://www.mathworks.com/matlabcentral/answers/7153-erfc-with-complex-number
But it is unlikely that will really help. You know how improbable it is that all the complex terms of an express will have their imaginary parts exactly cancel out, leaving a real-valued expression. Which is important because fzero() has behavior that is only well-defined for real-valued expressions.
You should probably be looking more carefully at why you are trying to take normcdf() of a complex value. Since your normcdf() expressions involve log(v/M) then what should come to mind immediately is that that log(v/M) would be complex if v/M < 0, which (for positive M) would happen if v < 0. Which, in terms of fzero(), corresponds to you needing a constraint to only search over positive v. And fzero() cannot provide such a constraint.
In other words, the optimization variable is going negative some situations, and your formula does not take that possibility into account, so the optimization goes crazy.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!