With Permutations(), Subsets(), Tuples() i can build nice lists without further editing/programming, they’re convenient to use. With an awkward combination of three functions i can build a Mma list which is a k-multiset. I can’t find a Multisets() function in the Documentation and Google points at various Mma-related posts on the topic, so multisets are used by people, people need such a function. I can understand why n multichoose k is not implemented as function because it is easily calculated as Binomial(k+n-1,k). I also cannot load the Combinatorica` package into my 11.3 session.
So basically i am just wondering and asking. What do we know about the implementation of a multisets function in Mma, was it ever considered and then dropped (when, why)?
Great stuff there, thank you!
None of these functions do what i am looking for but they are interesting on their own, i’ll study them in more detail.
Looking at that page, it seems like a Multisets() function was not implemented in the original mma release. I use a combination of Map(), Sort(), DeleteDuplicate(), and Tuples() to build a multiset.
Hi Raspi,
Are you using the desktop version? If so, you could create a package file containing definitions and functions, and then incorporate it into notebook files.
Here is an example notebook (.nb) of package definitions. Note the first line – each time you save it, a package (.m) file will automatically be created. Note also that all definitions are in Initialization cells (Ctrl-8).
To use the generated package, reference it from a .nb file:
Get["C:\\Users\\Authorized User\\Documents\\Mathematica\\community\\Example package.m"];
Print["alleles name = ", AllelesFreqDomainName];
Print["scrambled name = ", stringScramble[AllelesFreqDomainName]];
alleles name = Alleles Frequency
scrambled name = leqeleclFAusen ry
Rohit,
Thank you for the tips. I have been misunderstanding ‘:=’ as ‘define’, and also was unaware of RandomSample[] - which I’m reading has the desired properties.