You have stumbled onto a harder problem than you think it is. First, your final question, on certainty. You are asking to simultaneously optimize for the values p and q that, on expectation, satisfy your constraints, and optimize for the likelihood of them satisfying the constraints. There are a variety of ways to do this. One is to introduce a penalization term which penalizes uncertainty and is weighted based on to what extent you are willing to trade off certainty for fewer moves. How you weight these terms will determine the solution you get.
Another is to do an algorithmic approach where you choose some of the events and then recalculate your progress relative to your target, reoptimizing on the newly ideal p and q; so for instance if you expect that 3p and 5q will get you there, then maybe you start with q, do say 3 q, and then ask "okay, what do I need to do to get to where I'm trying to get from where I am now"; the new optimization might be 3p and 2q, or it might be some other figures depending on your probabilistic luck on the draws. This would be a heuristic approach and I don't have the time to think through whether this guarantees the minimum possible moves in expectation or if it would just give you a good-enough solution.
Now, your original solution. There are potentially multiple solutions (say for example you can choose between 2p and 1q or 1p and 2q, both satisfy your constraints). You appear to be saying that you are indifferent between those solutions, and want to simply minimize the total number of events regardless of which events they are. Thus you want to minimize p+q s.t. pE[P_x] + qE[Q_x] >= N_x , pE[P_y] + qE[Q_y] >= N_y , p>=0, q>=0. I'm not able to work out the best method to do this, but it visually on first inspection looks to me like a convex optimization problem. Solving it analytically is non-trivial.
However, I think you also over-asked your question by leaving it as general as you did. You're clearly working on something for Final Fantasy Record Keeper, like a way of telling people which levels to play to get the item drops they want. Personally (this is a modified pocket algorithm approach) I would just run a loop over p=1 to N, q=1 to N, if your inequalities hold, record the value of p+q, if it's lower than the previous minimum p+q, record the p and q values and the new minimum p+q value. If your loop runs and you find no combinations of p and q that satisfy the constraint, simply report that it's not feasible for the end user and you have no advice. If you have at least one satisfying combination, report the optimal one. Set N equal to half the maximum feasible number of events you think someone is willing to play to get the outcome they want (certainly no more than say 50). Ta-da.
Literally:
Code:
N=50
bestSum = 99999
bestPQ = (0,0)
for p in 1...N:
for q in 1...N:
if p*PX + q*QX >= NX and p*PY + q*QY >= NY and p+q<bestSum:
bestSum=p+q
bestPQ = (p,q)
if bestPQ != (0,0):
print p,q
else:
print "lol no"