I want to count and generate the number of non distinct integer partitions into k. I know that IntegerPartitions[n,{k}] returns the partitions of integer n into k.
E.g. IntegerPartitions[4, {2}] returns {{3, 1}, {2, 2}}. I want to count the frequency at which these occur e.g. 4 times for {3,1} and twice for {2,2}.
Edit
By this, I mean I can split 4 into {3,1} in 4 ways i.e. :-:---,-:-:--,--:-:- and ---:-: where the colons denote partitioning of the hyphens that comprise the number (here, 4). I count 4 ways with 'periodic boundary conditions'.
For the partitioning of 4 into {2,2} with the above notation, I find :--:-- and -:--:-, so 2 ways.
For IntegerPartitions[5, {2}], {4,1} and {2,3} occur 5 times (with periodic boundary conditions).
For the partitioning of 5 into {2,3} with the above notation, I find :--:---, -:--:--, --:--:-, ---:--: and -:---:-, so 5 ways.
Thank you!
Edit 2
As Domen says, and my examples attest, I assume pbc such that e.g. -:---:- is an example of an integer partition of 5 into {2,3}.
The case n=5 is still relatively simple, in that looking for integer partitions into k=2 returns only 2 distinct partitions. This grows with n, e.g. n=6 partitions into the 3 distinct partitions {1,5}, {2,4} and {3,3}. I want to compute the frequency of these/how many non distinct partitions there are.
I am working on a function but it is not streamlined.
Ideally, this would be called something like 'countIntegerPartitions', and take the integer 'n', partitions into 'k' as input. This is for a physics application (with instantaneous Gaussian distributed Hamiltonians H scaled such that H^2 on average gives the identity) in which I am only concerned with integer partitions into k=2. This function would return the integer partitions and the frequency at which these occur subject to pbc e.g. countIntegerPartitions[4,2] would return something like {{{3,1},4},{{2,2},2}}.
So far, I have created a repeating list of integers up to 2n and used the Partition function to partition this into partitions of length z where z is the largest integer in the partition pair. The partition function allows one to cycle through the list starting positions, and one can then count the number of distinct elements in the output list. For z = n/2, I need to divide by 2 to avoid double counting the partitions i.e. for n=6, {1,2,3} is equal to {4,5,6}. This is quite lengthly with for/if statements...
4 times for {3,1} and twice for {2,2}
: Could you elaborate upon this? How do you count4
andtwice
? $\endgroup$4 into {2,2}
is-:--:-
, but that sure looks like 3 partitions to me. $\endgroup$:--:--
and-:--:-
are the same, so only one way to do it. $\endgroup$