[EMAIL PROTECTED] wrote:
> 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
> 

Many thanks. I modified the recipes you attached some, and it works much 
better. Nice and informative answer!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to