# Create a list of random reals

How can I create a list of random pairs $(x,y)$ where $0<y<x<1$ and $x,y \in \mathbb{R}$ ? I can't seem to place that inequality restriction on the random numbers that are generated.

RandomReal[1, {100, 2}] /. {x_, y_} /; y > x :> {y, x}


The graphics below confirm that you retain a uniform distribution Generate random pairs, and reverse-sort each one:

Sort[#, Greater] & /@ RandomReal[1, {10, 2}]


or, for fun, generate two numbers between 0 and 0.5, and add the second to the first:

RandomReal[0.5, {10, 2}].{{1, 0}, {1, 1}}

• I don't believe the second method is valid: the smaller value can never exceed 0.5, incorrectly ruling out e.g. {0.8, 0.7}. – Mr.Wizard Jul 25 '14 at 20:41
• Note: While the second method has problems the first is correct, and it is four times faster than RunnyKine's (admittedly pretty) method. – Mr.Wizard Jul 26 '14 at 9:52

Another way is

{#, RandomReal[#]} & /@   RandomVariate[TriangularDistribution[{0, 1}, 1], 1000]


To see we do have a uniform distribution:

PDF[
TransformedDistribution[{x, y}, {
x  TriangularDistribution[{0, 1}, 1],
y  UniformDistribution[{0, b}]
}] /. b -> x,
{x, y}] • It looks like that is NOT an uniform distribution. – Silvia Jul 25 '14 at 20:12
• @Silvia yes it is not uniformly distributed – Algohi Jul 26 '14 at 3:51
• Maybe something like {#, RandomReal[#]} & /@ RandomVariate[TriangularDistribution[{0, 1}, 1], 100000]? – Silvia Jul 26 '14 at 8:08
• @Silvia Very good. Either edit this Answer to include that or post your own. – Mr.Wizard Jul 26 '14 at 9:51
• @Mr.Wizard done :) – Silvia Jul 26 '14 at 11:25