0

I need a way to randomly partition a rectangle into a given amount $N$ of subrectangles in a way that the distribution is as close as possible to uniform for testing purposes. I searched this website and found this post but it's not clear to me how the selected answer picks the next rectangle to push and I'm not sure it can generate any possible random split with a given amount of subrectangles, nor that the probability of the possible splits is uniform.

Are you aware of any algorithm or paper describing techniques that suit my purpose? I deeply appreciate!

  • What does uniform mean in this context? – Karl May 26 '22 at 20:09
  • @Karl: I would like that every possible split has the same probability of occurring given the number of subrectangles. If that's not possible even an approximation is fine for my purpose. – Baffo rasta May 26 '22 at 20:14
  • Ah, so you don't care about the sizes of the rectangles, just the finitely many qualitatively distinct splits for a given $N$. The answer to the linked post includes a proof that the algorithm can generate all splits. Also, if a split has no 4-way intersections ("+" shapes), then there's exactly one way for the algorithm to generate it, so the resulting distribution is uniform over those splits if you choose uniformly among your options at each step. – Karl May 26 '22 at 20:27
  • If you allow + shapes, then those splits can be obtained in multiple ways, so they'll occur more often than desired. You could compensate for this by choosing the +-creating moves with smaller probability than the other moves at each step. – Karl May 26 '22 at 20:30
  • 1
    @Karl: Gotcha, thanks for your remarks. I'm going to try an implementation and maybe even post it here. – Baffo rasta May 26 '22 at 20:39

0 Answers0