Solve for parameters of an integral (fsolve?)
조회 수: 3 (최근 30일)
이전 댓글 표시
Dear All, let a,c,d,e be real number parameters. Let x also be a parameter, which I would like to solve the attached equation for (using matlab). f(y) is a density function (for the beginning it can be a normal distribution). Can anyone point towards the general strategy to solve this and some useful commands?
Thanks in advance!
댓글 수: 0
답변 (1개)
Matt J
2016년 10월 27일
편집: Matt J
2016년 10월 27일
FZERO would be enough, I expect, since it is a 1D root finding problem. You can use commands like TRAPZ or INTEGRAL to get a numerical approximation of the integral. Also, in the case of a normal distribution, f(y), the integral of the terms (d+x)*f(y) can be evaluated using calls to the ERF command while the term y*f(y) has a closed analytical form.
댓글 수: 2
Matt J
2016년 10월 29일
roblocks replied
Dear Matt, thanks! I tried to implement, but I am running into a problem using the integral command. In a later version I want to solve for r. For now assume r is given and I would just like to compute the integral. The following code produces an error:
clear all; clc;
epsilon = 0.5;
r = 1.08;
D = 10;
r_s = 1.01;
mu = -1;
sigma = 8;
E_guess = 12;
r_guess = 1.08;
% define my function that is to be integrated over epsilon
second_summand = @(epsilon,r,D,r_s, mu, sigma, E_guess, r_guess)
((r*D+E_guess - (r_guess-1)-epsilon)*normpdf(epsilon,mu,sigma));
second_summand(epsilon,r,D,r_s, mu, sigma, E_guess, r_guess)
disp('second_summand function seems to be working.')
% clear epsilon to have it as a variable
clear epsilon
lb = E_guess - (r_guess-1)
ub = E_guess - (r_guess-1)+r*D
% compute the integral
integral( @(epsilon)
second_summand(epsilon,r,D,r_s, mu, sigma, E_guess, r_guess) ,lb , ub)
It simply copied what the integral reference page is suggesting for syntax if one uses parametric integrals.
Matt J
2016년 10월 29일
Use .* in your definition of second_summand so that it gives vectorized output.
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!