# Generate random numbers in such a way that their combinations meet the specified conditions

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

• It looks like you can at least generate $\alpha$ and $\beta$ independent of the other three... Feb 4, 2021 at 5:16
• 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
– Bill
Feb 4, 2021 at 6:17

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} *)


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 &]