5
$\begingroup$

I have a function that I'm trying to minimize. It currently works reasonably well with this:

FindMinimum[{chiSquared[ber, btm, dsr, dcd], 
  0 < ber && 0 < btm && 0 < dsr && 0 < dcd}, {{ber, 1.}, {btm, 
   10^10}, {dsr, 1.}, {dcd, 1000}}]

But the conditions seem like extra work. Is there an easier way to tell these kinds of functions that they should only consider positive, real numbers when working on a solution?

$\endgroup$
1
  • $\begingroup$ I do it like this: vars = {ber, btm, dsr, dcd}; init = {1., 10^10, 1., 1000}; FindMinimum[{chiSquared[ber, btm, dsr, dcd], Thread[0 < vars]}, Thread[{vars, init}]] -- maybe it's better? $\endgroup$
    – Michael E2
    Apr 21, 2020 at 21:57

1 Answer 1

6
$\begingroup$

This seemed to do the trick:

FindMinimum[{chiSquared[ber, btm, dsr, dcd], Element[{ber, btm, dsr, dcd}, PositiveReals]}, {{ber, 1.}, {btm, 10^10}, {dsr, 1.}, {dcd, 1000}}];
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.