0

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

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
dtn
  • 2,394
  • 2
  • 8
  • 18

2 Answers2

3

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} *)
JimB
  • 41,653
  • 3
  • 48
  • 106
2

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 &]
Daniel Huber
  • 51,463
  • 1
  • 23
  • 57