# Uniformly distributed numbers fulfilling conditions

I would like to generate 10 random lists of four elements (t, l, p, c) where these elements fulfill certain conditions. In particular:

0<t<5
0<l<1
0<p<3t
0<c<(p+4)4.


I tried the following:

Cases[RandomReal[{0, 1}, {10, 4}], {t_, l_, p_, c_} /;
0 < t < 5 && 0 < l < 1 && 0 < p < 3 t && 0 < c < (p + t)/4]


This however did not give 10 random lists.

Also, how can I refer to the elements of these lists? For example to the value of t in the 2nd random list?

region = ImplicitRegion[{0 < t < 5, 0 < l < 1, 0 < p < 3 t,
0 < c < (p + 4) 4}, {t, l, p, c}];

RandomPoint[region, 10] // MatrixForm // TeXForm


$\left( \begin{array}{cccc} 1.68766 & 0.836391 & 2.93869 & 22.1238 \\ 4.62474 & 0.47504 & 8.4518 & 23.3757 \\ 3.98097 & 0.352805 & 9.81347 & 54.3231 \\ 3.54265 & 0.328488 & 0.352232 & 10.8121 \\ 4.75769 & 0.217224 & 5.23698 & 18.4434 \\ 4.30327 & 0.0832155 & 11.559 & 25.6348 \\ 2.80042 & 0.0322461 & 0.666347 & 0.00504684 \\ 1.50558 & 0.935574 & 3.20578 & 4.23713 \\ 2.58958 & 0.577877 & 4.67873 & 1.762 \\ 1.65042 & 0.468702 & 1.72952 & 2.20419 \\ \end{array} \right)$

RandomPoint[reg]
gives a pseudorandom point uniformly distributed in the region reg.

RandomPoint[reg, n]
gives a list of n pseudorandom points uniformly distributed in the region reg.

Table[{t = RandomReal[{0, 5}],
RandomReal[{0, 1}],
p = RandomReal[{0, 3 t}],
RandomReal[{0, (p + 4) 4}]},
{10}]

(*
{{2.9017, 0.425688, 8.62538, 22.1976},
{2.58804, 0.367606, 1.71088, 21.9777},
{1.49444, 0.89547, 3.01776, 3.2332},
{2.22815, 0.536662, 6.47264, 32.5914},
{0.0792402, 0.770279, 0.0665581,6.36914},
{3.29393, 0.62593, 0.962989, 11.428},
{2.91513, 0.928765, 8.33419, 24.1203},
{1.45567, 0.0264987, 1.41981, 4.06425},
{1.72574, 0.620271, 3.82514, 24.1868},
{3.63564, 0.937071, 1.82518, 0.856747}}
*)


To the first part of your question:

Just write down the definition of the variables with their conditions

t := RandomReal[5]
l := RandomReal[1]
p := RandomReal[3 t]
c := RandomReal[4 (4 + p)]


then form one list

x:={t,l,p,c}


and finally generate 10 lists

xa=Array[x&,10]

{{0.81632, 0.150935, 4.17455, 15.9769}, {4.59785, 0.0985758, 1.60776,
2.19325}, {1.96392, 0.966806, 3.78854, 26.035}, {3.16595, 0.224949, 7.58408,
3.06743}, {0.590463, 0.70165, 0.470683, 5.07829}, {2.08984, 0.402493,
0.494039, 5.56079}, {2.63064, 0.461462, 0.417904, 22.6917}, {0.0377497,
0.840235, 4.49982, 20.8807}, {4.45266, 0.48599, 3.98964, 4.57971}, {3.50745,
0.0520926, 8.12091, 0.140059}}


The values of t, l, etc. are the respective rows of the transposed Matrix

txa = Transpose[xa]

{{0.81632, 4.59785, 1.96392, 3.16595, 0.590463, 2.08984, 2.63064, 0.0377497,
4.45266, 3.50745}, {0.150935, 0.0985758, 0.966806, 0.224949, 0.70165,
0.402493, 0.461462, 0.840235, 0.48599, 0.0520926}, {4.17455, 1.60776,
3.78854, 7.58408, 0.470683, 0.494039, 0.417904, 4.49982, 3.98964,
8.12091}, {15.9769, 2.19325, 26.035, 3.06743, 5.07829, 5.56079, 22.6917,
20.8807, 4.57971, 0.140059}}


For example, the first element gives the list of the values of t,

txa[[1]]

{0.81632, 4.59785, 1.96392, 3.16595, 0.590463, 2.08984, 2.63064, 0.0377497,
4.45266, 3.50745}


the second one that for l

txa[[2]]

{0.150935, 0.0985758, 0.966806, 0.224949, 0.70165, 0.402493, 0.461462, \
0.840235, 0.48599, 0.0520926}


and so on.

As a check of the formulas used in the first part you can for instance compare the theoretical value of the mean of c

Integrate[16 r + 60 r s u, {r, 0, 1}, {s, 0, 1}, {u, 0, 1}]

31/2 // N

15.5


with the experimental values (in this case 5)

Array[Mean[Array[c &, 10^3]] &, 5]

{14.7292, 15.3443, 15.7023, 16.305, 14.8933}