Computation of sum/product of triple integral using function handle
Show older comments
Consider a set of non-negative real values
,
and
.
,
.First, I want to compute f as a function of θ vector:
However, I am mainly interested in calculating the natural logarithm of this function. Namely:
I coded this for the case of a single
as:
as:% Inputs:
t = 15;
sigma = 0.25;
y = 1.0;
h = @(x1,x2,x3) x1.*(t - x2).^x3;
g = @(x1,x2,x3) exp(-0.5.*((y - h(x1,x2,x3))./sigma).^2 );
f = @(x1,x2,x3,theta) g(x1,x2,x3).*theta(1).*theta(2).*theta(3).*theta(4);
J1 = @(theta) integral3(@(x1,x2,x3) f(x1,x2,x3,theta), 0, 1, 0, t, 0.3, 1);
J2 = @(theta) log(J1(theta));
...but I don't know how to do it for the general case of multiple
. Any idea please?
. Any idea please?3 Comments
Note that the theta-dependence is trivial. Because the product over the thetas can be factored out of the triple integral, the function is really,
logf=n*sum(log(theta)) + constant
If this is a loglikelihood you are minimizing, the constant term is irrelevant. It is independent of theta and doesn't influence the minimization.
DIMITRIS GEORGIADIS
on 3 Nov 2021
Edited: DIMITRIS GEORGIADIS
on 3 Nov 2021
DIMITRIS GEORGIADIS
on 4 Nov 2021
Edited: DIMITRIS GEORGIADIS
on 4 Nov 2021
Accepted Answer
More Answers (1)
If you can do this for a single y_i, then it should be trivial for multiple y_i. Note that the y_i can be factored out of the integral as well, so that
logf=n*sum(log(theta)) -sum(y)/2 + constant
where the constant is obtained by doing the integral with all theta=1 and y=0. Since you say you can already do these, the problem is solved.
Categories
Find more on Numerical Integration and Differentiation 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!