MATLAB: How to find the sum of a function with 2 variables

integrationvariables

Hi,
I'm trying to find the sum of the function likelihhod, after the values from smaller is inserted. Then I want to integrate the new function for the variables d1 and d2 with the limits given bellow. But when I try this approche it only crashes. Can anyone tell me how I can do this?? Thanks!
smaller = [1650,1660,1656,1649];
m = numel(smaller);
q = 1657;
likelihood = @(d1,d2) sum(log((d2./d1).*(smaller./d1).^(d2-1).*...
exp(-(smaller./d1).^d2)))+ log(exp(-(q/d1)^d2);
integration = integral2(@d1,d2)likelihood(d1,d2),1000,2000,30,230)

Best Answer

I would break down the likelihood expression into smaller expressions in order to narrow down on the error. For example
a = @(d1,d2) (d2/d1)*(smaller./d1)
b = @(d1,d2) (d2-1)*exp(-(smaller./d1).^d2);
x = @(d1,d2) log(a(d1,d2).^b(d1,d2));
y = @(d1,d2) (exp(-(q/d1)^d2));
likelihood = @(d1,d2) sum(x(d1,d2))+y(d1,d2);
integration = integral2(likelihood,1000,2000,30,230);