def random_element(self): r""" Return a uniformly random element of ``self``. ALGORITHM: This uses the :meth:`~sage.combinat.posets.posets.FinitePoset.random_order_ideal` method and the natural bijection with plane partitions. EXAMPLES:: sage: P = PlanePartitions((4,3,5)) sage: P.random_element() Plane partition [[4, 3, 3], [4, 0, 0], [2, 0, 0], [0, 0, 0]] """ def leq(thing1, thing2): return all(thing1[i] <= thing2[i] for i in range(len(thing1))) elem = [(i,j,k) for i in range(self._box[0]) for j in range(self._box[1]) for k in range(self._box[2])] myposet = Poset((elem, leq)) R = myposet.random_order_ideal() Z = [[0 for i in range(self._box[1])] for j in range(self._box[0])] for C in R: Z[C[0]][C[1]] += 1 return self.element_class(self, Z, check=False)