I have a code that illustrates a certain figure.
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[
declare function={ Nprime(\x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(\x,2)));
d2(\x,\y,\KK,\RR,\SIG) = (ln(\x/\KK)+(\RR-(pow(\SIG,2)/2)*\y))/(\SIG*(sqrt(\y)));
myfun(\x,\y,\KK,\RR,\SIG) = exp(-\RR*\y)*Nprime(d2(\x,\y,\KK,\RR,\SIG))/(\x*\SIG*sqrt(\y));
},
]
\begin{axis}[y domain=0.01:0.3,domain=95:105,view={150}{20}]
\addplot3[surf] {myfun(x,y,100,0,0.09)};
\end{axis}
\end{tikzpicture}
\end{document}
Instead of Nprime(\x)
I would like to declare and integrate a cumulative distribution function `N(\x). A very close approximation of cumulative distribution function would also be fine. Everything else should remain equal. Does anybody know how to do it? Thanks in advance!!!
Here is the formula: enter link description here
Something similar is provided here enter link description here but I dont know how to integrate is according to my needs 🙁
Here is a modified version that doesn't work. The last part of the function, i.e. (\x*\SIG*sqrt(\y)) was removed because it is not needed in this case. Here is the code
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[
declare function={ normcdf(\x,\m,\s) = 1/(1 + exp(-0.07056*((\x-\m)/\s)^3 - 1.5976*(\x-\m)/\s));;
d2(\x,\y,\KK,\RR,\SIG) = (ln(\x/\KK)+(\RR-(pow(\SIG,2)/2)*\y))/(\SIG*(sqrt(\y)));
myfun(\x,\y,\KK,\RR,\SIG) = exp(-\RR*\y)*normdcf(d2(\x,\y,\KK,\RR,\SIG))
},
]
\begin{axis}[y domain=0.01:0.3,domain=95:105,view={150}{20}]
\addplot3[surf] {myfun(x,y,100,0,0.09)};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
There are three issues in your code:
myfun
. All functions defined usingdeclare function
have to end with a semicolon.normcdf
, notnormdcf
).normcdf
function. It takes three parameters: The x value, the mean, and the standard deviation of the normal distribution.