0
$\begingroup$

We need to generate 5 numbers $\alpha,\beta,p,q,k$ so that they meet the following conditions:

  1. $\alpha,\beta,p,q,k>0$
  2. $k \cdot p <1$
  3. $k \cdot q >1$

Edit:

I think, that this code may be solution:

region = ImplicitRegion[\[Alpha] > 0 && \[Beta] > 0 && p > 0 && q > 0 && k > 0 && k p < 1 && k q > 1, {\[Alpha], \[Beta], p, q, k}];

RandomPoint[region]

But this still very slowly!

Generate two random numbers with constraints

$\endgroup$
2
  • 2
    $\begingroup$ It looks like you can at least generate $\alpha$ and $\beta$ independent of the other three... $\endgroup$
    – J. M.'s torpor
    Feb 4 at 5:16
  • 2
    $\begingroup$ While[True,{a,b,p,q,k}=RandomReal[{0,2},5];If[k*p<1&&k*q>1,Break[]]];{a,b,p,q,k} completes almost instantly $\endgroup$
    – Bill
    Feb 4 at 6:17
3
$\begingroup$

I think you need to specify what kinds of distributions you want to consider. Otherwise there are infinite numbers of possibilities. Here's one:

x = RandomVariate[ChiSquareDistribution[1], {1000, 5}];
{α, β, p, q, k} = Select[x, #[[3]] #[[5]] < 1 && #[[4]] #[[5]] > 1 &][[1]]
(* {0.198549, 0.0376487, 0.0248636, 1.00516, 1.8256} *)
$\endgroup$
2
$\begingroup$

Assuming you want a uniform distribution, you must specify some upper bound. For an example I choose an upper bound of 1. The lower bound is ">0", but as the probability of choosing zero is zero, we may simply choose the lower bound as zero:

While[ {a, b, p, q, k} = RandomReal[{0, 1}, 5]; k p > 1 || k q > 1]
{a, b, p, q, k}
AllTrue[{k p, k q}, # < 1 &]
$\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.