![]() |
|
Problems? Is your data what you think it is? | |
PerlMonks |
Re^2: Faster alternative to Math::Combinatoricsby AppleFritter (Vicar) |
on Sep 01, 2017 at 16:43 UTC ( #1198531=note: print w/replies, xml ) | Need Help?? |
It's intentional — I'm only looking for unordered tuples. Think of it as simultaneously drawing w (e.g. 3) balls from an urn containing at least w balls each marked n for any element of the underlying list (e.g. (0, 2, 3)). Generating all possible permutations would be quite easy, otherwise. I actually briefly entertained the thought of generating all possible tuples and then removing ones that are in the same equivalence class as previously-seen ones, but for larger w and longer lists, this would take a fair amount of time and memory. w won't go beyond 8, but the lists might be arbitrarily long, at least in theory. (Without having checked I actually have a gut feeling that this is what Math::Combinatorics might be doing under the hood — it would explain why it's so slow, and why the first multisets I draw from it appear much faster than the later ones!)
Yeah, that's definitely an option. But I'm lazy (it's one of the chief virtues of a programmer!), and therefore prefer to, in order:
Thanks for taking the time to reply, BTW!
In Section
Seekers of Perl Wisdom
|
|