0
$\begingroup$

I want two(2) numbers $\phi_{1}, \quad \phi_{2}$ such that the following five(5) conditions will be satisfied using R:

  1. $ \phi_{1} + \phi_{2} < 1 $
  2. $ \phi_{1} - \phi_{2} < 1 $
  3. $ -1 < \phi_{1} < 1 $
  4. $ -1 < \phi_{2} < 1 $
  5. $\phi_{1}$ and $\phi_{2}$ are in one(1) decimal place
$\endgroup$
  • 3
    $\begingroup$ $$\phi_1=\phi_2=0$$ $\endgroup$ – Xi'an Jan 12 at 12:01
  • $\begingroup$ This is called a linear program and the subject that addresses its solution is called linear programming. The particular problem of finding a solution is called finding a feasible solution. $\endgroup$ – whuber Jan 12 at 14:09
4
$\begingroup$

Brute force, not much thinking: $\phi_1$ and $\phi_2$ are both between -1 and 1 and they are given to one decimal place. That makes them discrete and we can simply test all possible combinations of $\phi_1$ and $\phi_2$.

phi1 <- seq(-.9, .9, .1)
phi2 <- seq(-.9, .9, .1)
grid <- expand.grid(phi1 = phi1, phi2 = phi2)

grid$condition1 <- grid$phi1 + grid$phi2 < 1
grid$condition2 <- grid$phi1 - grid$phi2 < 1

grid$valid <- grid$condition1 & grid$condition2
valid.combinations <- grid[which(grid$valid),]

plot(grid$phi1, grid$phi2, xlim = c(-1, 1), ylim = c(-1,1), col = "grey", ,
      xlab = expression(phi[1]), ylab = expression(phi[2]))
points(valid.combinations$phi1, valid.combinations$phi2, pch = 16)

enter image description here

$\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.