A preference relation (total preorder, weak order) on a set $S$ is a binary relation $ \precsim $ on $S$ that satisfies:
- completeness: for any $x, y \in S$, either $x \precsim y$ or $y \precsim x$
- transitivity: for any $x, y, z \in S$, if $x \precsim y$ and $y\precsim z$, then $x \precsim z$
The number of preference relations on a finite set of cardinality $n$ is given by the ordered Bell number $a(n)$:
$$ a(n) = \sum_{k=0}^n \sum_{j=0}^k (-1)^{k-j} {k \choose j} j^n $$
My question is, how to generate a random preference relation on a finite set uniformly? For example, there are $13$ preference relations on $3$ elements, so each of them should have a probability $1/13$ of being chosen.
Of course, I want the algorithm to have computational complexity as low as possible.
What about a simple recursive algorithm, where you first generate a preference for $n-1$ elements, then put the last one either on one of the equivalence classes, or between two of them, or at first or last position?