Probability computation with MATLAB (involves computing an integral)

1 view (last 30 days)
Hello everyone, I am running some analysis with MATLAB for my thesis and need to compute this probability:
where the fj function that you see there is, for example, of the form:
In particular, I will have a P1 obtained via f1 and a P2 obtained via f2 respectively. I already wrote the code for the f1 function, that is:
function [ f_one ] = f_one(S, R, V, rho, tau, lambda, mu_j, sigma_j,...
theta_R, sigma_R, xi_R, k_R, ...
theta_v, sigma_v, xi_v, k_v)
% formula for f1 characteristic function
f_one = exp(-(theta_R./sigma_R^2).*(2.*log(1-((xi_R-k_R).*(1-exp(-xi_R.*tau)))./(2.*xi_R))+(xi_R - k_R).*tau)...
- (theta_v./sigma_v^2).*(2.*log(1-((xi_v-k_v+(1+1i.*phi).*rho.*sigma_v).*(1-exp(-xi_v.*tau))))./(2.*xi_v))...
- (theta_v./sigma_v^2).*(xi_v-k_v+(1+1i.*phi).*rho.*sigma_v).*tau+1i.*phi.*log(S)...
+ R.*(2.*1i.*phi.*(1-exp(-xi-R.*tau)))./(2.*xi_R-(xi_R-k_R).*(1-exp(-xi_R.*tau)))...
+ lambda.*(1+mu_j).*tau.*((1+mu_j)^(1i.*phi).*exp((0.5.*1i.*phi).*(1+1i.*phi)...
.*sigma_j^2)-1)-lambda.*1i.*phi.*mu_j.*tau...
+ V.*(1i.*phi.*(1i.*phi+1).*(1-exp(-xi_v.*tau)))./(2.*xi_v-(xi_v-k_v+(1+1i.*phi).*rho.*sigma_v).*...
(1-exp(-xi_v.*tau))));
end
Does anybody could please give me any suggestion on how should I proceed to computes the Pjs? I read on the documentation that I should make use of "integral" and functions handles, but don't really know how to do it so far. Thank you.

Accepted Answer

Jeff Miller
Jeff Miller on 27 Oct 2018
To compute the integral part, you basically want a command like:
thisintval = integral(@(theta) Re(theta,otherparms),0,inf); % Optionally specify tolerances.
The function Re(theta) has to return the value of Re[stuff in square brackets]. Your f_one function is part of that, but not all. You can list out all of the other parm values one by one, encapsulate them all as separate fields within one structure, or use an object-oriented approach.

More Answers (0)

Categories

Find more on Financial Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!