0
votes

I'm trying to integrate the function. I'm getting the error Undefined function 'int' for input arguments of type 'double'. Here is my code:

P = @(m,sigma,t,C) (normcdf((C-m/sigma)/sqrt(t),0,1) - exp(2*C*m/sigma)*normcdf((-C-m/sigma)/sqrt(t),0,1));
Pr = @(m1,m2,sigma_1, sigma_2,t,C) (P(m1,sigma_1,t,C)*P(m2,sigma_2,t,C));
P_S = @(m1,m2,sigma_1,sigma_2,C) (1 - int(Pr(m1,m2,sigma_1,sigma_2,t,C), t, 0, inf));

What am I doing wrong and how to integrate this function?

1

1 Answers

0
votes

normcdf is used for floating point calculations and does not support symbolic input. You need to write your own. Luckily that's pretty easy. Try replacing normcdf with this:

normcdf_sym = @(x,mu,sig) (1./(sig*sqrt(2*sym('pi'))))*int(exp(-(t-mu).^2./(2*sig.^2)),t,-Inf,x);

Or with this, which is is equivalent to the above:

normcdf_sym = @(x,mu,sig) (1+erf((x-mu)./(sig*sqrt(2))))/2;

Also, you'll likely want to define your symbolic variables as real: syms m sigma t C real;. Or use the assume and assumeAlso functions.

All this is assuming you want to use symbolic integration in the first place, as opposed to numeric integration.