Re: Partition Function
- To: mathgroup at smc.vnet.net
- Subject: [mg57662] Re: Partition Function
- From: "Dana DeLouis" <delouis at bellsouth.net>
- Date: Fri, 3 Jun 2005 05:33:59 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
> ... According to the documentation, "NextPartition[p] gives the > integer partition following p in reverse lexicographic order." > > Now when I try it, even in a fresh Mathematica session, I get... > nothing. Is this a bug or am I just misusing the function? Hi. NextPartition works with a previous partition instead of just a number like 4. I really like this package, but I wish there was "better" documentation on these functions. Anyway, here's an example: Needs["DiscreteMath`Combinatorica`"] Here's a list of partitions: Partitions[4] {{4}, {3, 1}, {2, 2}, {2, 1, 1}, {1, 1, 1, 1}} NextPartition[{2, 2}] {2, 1, 1} It may be easier to just start of with the number in list form: NextPartition[{4}] {3, 1} Looks like NextPartition cycles: NestList[NextPartition, {4}, NumberOfPartitions[4] + 7] {{4}, {3, 1}, {2, 2}, {2, 1, 1}, {1, 1, 1, 1}, {4}, {3, 1}, {2, 2}, {2, 1, 1}, {1, 1, 1, 1}, {4}, {3, 1}, {2, 2}} Just another example: NestList[NextPartition, {4}, NumberOfPartitions[4] - 1] {{4}, {3, 1}, {2, 2}, {2, 1, 1}, {1, 1, 1, 1}} HTH Dana DeLouis