maximize function in multiple variables symprod
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have 2 functions PL and PR with µ and sigma as unknown variables and ti and tj are known. PL and PR are given by:
PR=[exp(exp(-(log(t1)-µ)/sigma))]*[exp(exp(-(log(t2)-µ)/sigma))]*[exp(exp(-(log(t3)-µ)/sigma))]*...*[exp(exp(-(log(ti)-µ)/sigma))]
PL=[1-(exp(exp(-(log(t1)-µ)/sigma)))]*[1-(exp(exp(-(log(t2)-µ)/sigma)))]*[1-(exp(exp(-(log(t3)-µ)/sigma)))]*...*[1-(exp(exp(-(log(tj)-µ)/sigma)))]
Thus, PL and PR are both the product of a number of terms.
Now I need to maximize a function L which is the product of the 2 functions PL and PR. In other words, L=PL*PR should be maximized for a certain µ and sigma. To make it clear, I attached the formulas as a figure.
I known I can use fminsearch or fminunc to search for the maximum of this function by evaluating it in µ and sigma. The only thing is that I need a for loop to calculate the product of all the individuals terms of PR and another for loop for the product of the terms of PL, as symprod is not working. The matlab codes for this are:
PL=1;
for j=1:n
PL = PL*(1-exp(-exp((log(tno(j,1)-µ)/sigma))));
end
PR=1;
for i=1:n
PR = PR*(exp(-exp((log(tyes(i,1)-µ)/sigma))));
end
Does anyone know how to evaluate the function L=PL*PR in µ and sigma to determine its maximum?
Thank you!
1 comentario
Walter Roberson
el 28 de Dic. de 2016
Code simplification:
PL = prod( 1 - exp(-exp((log(tno(1:n,1)-mu)/sigma))) );
PR = prod( exp(-exp((log(tyes(1:n,1)-mu)/sigma))) );
and in the special case where tno and tyes are vectors of length n,
PL = prod( 1 - exp(-exp((log(tno-mu)/sigma))) );
PR = prod( exp(-exp((log(tyes-mu)/sigma))) );
Respuestas (1)
Walter Roberson
el 29 de Dic. de 2016
Unless there are constraints, then the maximum is indefinitely large at mu arbitrarily close to one of the tno values.
Sort the tno values by value.
If the number of tno values is odd, then the maxima occurs at arbitrarily small values greater than the 2nd, 4th, 6th, etc values.
If the number of tno values is even, then I suspect the maxima occurs at arbitrarily small values less than the 1st, 3rd, 5th, etc values, but I have not proven this.
This maxima can be shown when sigma = -1.
0 comentarios
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!