TITLE: Uniformly Sampling from Convex Polytopes
QUESTION [20 upvotes]: How to choose a point uniformly from a convex polytope $P \subset [0,1]^n$ defined by some inequalities,  $Ax < b$? (Here $A$ is an $m \times n$ matrix, $x \in \mathbb{R}^n$, and $b \in \mathbb{R}^m$.)  I imagine that you could start with a uniformly chosen point in the cube and do some process to get a point with $Ax < b$.

REPLY [16 votes]: Hit and run sampling will perform much better than rejection sampling for higher dimensions.
It converges to a uniform distribution in polynomial time. The basic idea is to start at any point $x_0$ inside the polytope, then follow the following procedure iteratively:

pick a direction $\alpha$ uniformly at random.
find the minimum and maximum value of $\theta$ such that $x_n+\theta\cdot\alpha$ is contained in the polytope
pick a $\theta^*$ uniformly at random from $[\theta_{min},\theta_{max}]$
your new point is $x_{n+1}=x_n+\theta^*\cdot\alpha$