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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!