On May 22, 11:19 am, Efrat Regev: > I want to iterate over all > such vectors under the constraint that the granularity of > each component is at most some delta.
You can think of this like your sum is an integer>=1 and the single "probabilities" are integers>=1 So given the sum, like 6, you can find all the parts of it, and then find all the permutations of such parts. Eppstein has given code for the parts of an integer, and you can can find the iterable permutations code on the cookbook. But the number of such possible vectors grows very quickly... http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/218332 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/474124 Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list