Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [partitions]

this tag is used for questions regarding splitting a list into sublists

1
vote
1answer
34 views

How to find efficiently the independent vertex sets from a large adjacency matrix?

I have a binary adjacency matrix $M$ of size $72\times 72$. I would like to find all possible combinations of 18 non-adjacent nodes. There are $^{72}C_{18}$ possible (adjacent and non-adjacenct) ...
7
votes
2answers
299 views

How to color nodes in a adjacency graph with different colors?

Let us consider a binary adjacency matrix $M$. We want to color the nodes of corresponding adjacency graph with 4 different colors such that two adjacent nodes have different colors. How to find 4 ...
4
votes
2answers
134 views
1
vote
0answers
24 views

How to form sets of non-adjacent subgraphs from all possible subgraphs and the adjacency matrix?

I have connected graph with $72$ nodes. The binary adjacency matrix of the connected graph is $A$. The size of $A$ is $72\times 72$ and its symmetric. I have generated all possible subgraphs ($17000$...
7
votes
2answers
152 views

Partitioning a set of integers

I have a set of ordered integers, e.g. {1,2,3,6,7,9,10} and I would like to partition the set in subsets of sequential numbers, e.g. ...
0
votes
2answers
45 views

Partitioning Mixture Distribution Dataset into constituent Distributions

Suppose I have a dataset that is derived from a random sampling from a mixture distribution ...
2
votes
0answers
24 views

Partition data but dropping elements between each sublist

Is there a neat way to partition a list into sublists of fixed length $n$, discarding a fixed number $k$ elements between each one? E.g for $n=3, k=1$, ...
1
vote
0answers
37 views

In what order does Combinatorica's SetPartitions function list the partitions of a set?

For example, Needs["Combinatorica`"] n = 4; partitions = SetPartitions[Range[n]]; Table[Print[partitions[[i]]], {i, 1, BellB[n]}] generates ...
0
votes
0answers
27 views

Enumerate all lists of $m$ non-negative integers that add to $n$ [duplicate]

Let $x_1,\dots,x_m$ be non-negative integers such that $\sum_{i=1}^m x_i=n$, where $m,n$ are given. How can I enumerate all such lists of $m$ integers that add to $n$? Note that ...
4
votes
2answers
48 views

Groupings of the Elements of a List with at Most $k$ Elements

Given a list with $n$ elements and an integer $k$ I want to get a list with all possible groupings of these n elements in sets with at most k elements. For example, given $n=\{1,2,3,4\}$ and $k=3$ I ...
3
votes
2answers
192 views
4
votes
1answer
121 views
1
vote
1answer
35 views

Find vertices of a hypercube given a set of partitions

Problem The goal is to take a set of $n$ linear partitions $\left\{p_{k}\right\}_{k=1}^{n}$ and create a hypercubic partition: $$ \mathbf{P}=p_{1}\times p_{2}\times \cdots\times p_{n} $$ Each ...
2
votes
2answers
109 views

Totally orderless partition

This is a slight variation of: How to generate all possible orderless partitions of a list according to another list? Consider each set following a partition a "box" and each element a "ball". What ...
-1
votes
1answer
38 views

RecursionLimit error when summing over partitions

I'm computing a recursion of polynomials W[g,n] (which is polynomial in L[1],...,L[n], but keep running into the recursion depth error. I have determined which part of the recursion is causing this, ...
4
votes
1answer
162 views

solid partitions generator

According to Wikipedia, a solid partition of $n$ is a three-dimensional array $n_{i,j,k}$ of non-negative integers (with indices $i,j,k \geq 1$) such that $$\sum_{i,j,k} n_{i,j,k}=n$$ and $$n_{i+1,j,k}...
2
votes
2answers
88 views

Graph with multiple partitions

I have an edgelist ...
0
votes
1answer
46 views

Please explain the following code containing Partition and Flatten

I'm a beginner in Mathematica. I have the following code: A = NestList[func, x0, n]; B = Partition[Flatten[{#, #, #, #} & /@ A][[2 ;; -2]], 2] I don't ...
0
votes
1answer
49 views

function that generates a list of all plane partitions of a given dimension

Is there a function in Mathematica that generates a list of all plane partitions of a certain dimension $n$? This paper describes the algorithm, but I still find it a bit tricky to do it myself.
4
votes
2answers
118 views

Partition with offset and varying size

Assume I have the list below. list=Range@20; Desired partition is: {{1,2,3,4},{4,5,6,7,8},{8,9,10,11,12},{12,13,14,15,16},{16,17,18,19,20}} I have tried <...
2
votes
2answers
110 views

Counting the permuted partitions

With IntegerPartitions[7], I have partitions of 7 into integers that are smaller than 6 as follows. ...
5
votes
5answers
413 views

How can I extract parts from a ragged nested list?

I have given the following list list = {a, {b, c, d, e}, {e, f, h, i}} Is there a direct way to use Part specification to get ...
4
votes
1answer
115 views

Partitioning a sparse matrix into sparse sub-matrices

Given a normal matrix, for example m = Array[a,{4,4}] which has dimensions {4,4}, I can partition it by using: ...
1
vote
0answers
100 views

Partition a set of n objects into k subsets? [duplicate]

Is there some function recently added to Mathematica that facilitates forming all partitions of a n-element set into k subsets? In other words, something that easily gives the same thing as what <...
1
vote
2answers
118 views

Comparing elements in a list of lists

I'm stuck with yet another list question. The basic gist: I have lists within a list like so: ...
1
vote
2answers
76 views

Why did Riffle mess up? [closed]

I have a list x95 (notice how the increment changes from 0.05 to 0.005 towards the end): ...
4
votes
2answers
219 views

Manipulating Elements in a Triple-Nested List

I have been working on a triple-nested list, called datasections, of the given form: ...
10
votes
6answers
756 views

Is there concise code for the list operation I want to perform?

Is there any concise syntax for the following partitioning of a list. Given {1, 2, 3, 4}, I want to get the output as shown below. I have tried various function ...
0
votes
0answers
24 views

Function seems to be evaluating before giving it a value [duplicate]

I'm trying to take a list of coordinates and convert the right ascensions and declinations from h min s / deg arcmin arcsec to degrees. This is my list of coordinates ...
2
votes
2answers
318 views

Partition vector

I have a vector composed of 10 elements and I want to "split" it into two vectors composed of five elements: q={1,2,3,4,5,6,7,8,9,10};Partition[q,5] but the ...
3
votes
3answers
141 views

How to get a description of the positions of similar elements in a list

I want to find a function F to represent the positions of identical elements in a list, which means, for example: ...
1
vote
0answers
59 views

Partitioning a dataset and repetitively subtracting off a shift, ie: folding data back onto itself. [closed]

I have some oscilloscope data of a repetitive experiment occurring every 50ms. At 2.5us between points every "mini-experiment" is 20,000 pts long (see plot below for a short sample). What I want ...
6
votes
3answers
185 views

How to find most complete partition of a list

How to find most complete partition of a list? For example: list1={5,8} list2={4,4,2,3,6} 8 can be comprised of {4,4} or <...
2
votes
1answer
80 views

Cut a list of length `n` into even number `m` of adjacent sublists of odd length in all possible ways?

Consider a list with all different entries of length n, i.e. for n=6: list = {1,2,3,4,5,6}; ...
3
votes
1answer
31 views

Non-Constant Partitioning of a List with Order Analysis [duplicate]

Let's say I have a set of numbers "r" whose sum equals 15, and I want to randomize all values up to and including that sum from and including 1 into a set called "a". So far I have this: ...
3
votes
2answers
190 views

Sum over partitions of a number

I know only some basics about mathematica. However I need to write down the following sum: $\sum_{\{m_k\}_N}\prod_{k=1}^N\frac{1}{m_k}[T_k(Z(\tau))]^{m_k}$. Where $\{m_k\}_N$ denotes partitions of ...
10
votes
6answers
642 views

Partition a list by count of a number

I want to take this list when the 2 appear 3 times SeedRandom[1] list = RandomChoice[{.2, .5, .3} -> {1, 2, 3}, 20] ...
4
votes
1answer
138 views

A partition problem

I want to find all partitions of the set $\{1,2,\ldots,40\}$ into disjoint sets $A$ and $B$ such that no subset of $B$ has a sum that is a member of $A$? I have an algorithm for doing this although ...
20
votes
3answers
781 views

Partitioning a number into consecutive integers

Consider n=45; then $$1+2+3+4+5+6+7+8+9=45$$ $$5+6+7+8+9+10=45$$ $$7+8+9+10+11=45$$ $$14+15+16=45$$ $$22+23=45$$ Question: how to find all representations of a ...
2
votes
1answer
56 views

Partition lists into sub-lists based on whether they are consecutive or not [duplicate]

I am new to Mathematica and would appreciate any help. I'd like to partition my data which is comprised of {time x analog input} into sublists of consecutive time. In other words, my data looks like ...
2
votes
3answers
111 views

How to get the N Mth (e.g. 1st 4th, 5th 8th etc of) a dataset?

With all the tools and commands for segmenting lists, I'm having a hard time finding something to do the following: I want to programmatically subset the Nth Mth of a list. This could be the 1st 4th, ...
6
votes
1answer
73 views

Non-trivial partitions of numbers using Combinatorica

I have made a code which gives back partitions of numbers in two Young diagrams (one Young diagram is trivial). For example, the partitions of 1 are ...
19
votes
6answers
605 views

How to generate all possible orderless partitions of a list according to another list?

This question is hard to describe in plain text. So I will post an example and a working code (brute force) to illustrate. For example I have a list: ...
3
votes
3answers
133 views

Variable iterator in Do Loop (splitting a list)

I have a list in Mathematica that looks like the following: {{92,3},{23,3},{93,3},{63,2},{66,2},{24,4},{94,4},{27,4},{72,4},....} The point is that the second ...
6
votes
3answers
370 views

Any alternative way to compute IntegerPartitions?

I tried to compute IntegerPartitions[100] using mathematica on my intel core i3 system. the system hangsup everytime. Is there another way to do such a large computation?
1
vote
1answer
140 views

How to build a matrix from blocks [duplicate]

Brief MWE Given ...
4
votes
2answers
291 views

Elegant way to partition list to be faster than `ParallelTable` (using `ParallelSubmit`), or some alternative?

Suppose you have a function fun[x_] := (Pause[.05*x]; x^2); of which you know that its evaluation time increases with its argument - in this case obviously ...
9
votes
3answers
538 views

GatherBy/SplitBy and Sort a list

So let's say I want to group a list of points based on their distance from the origin. I would do something like: ...
8
votes
4answers
611 views

Goldbach Partition

I want to check the Goldbach conjecture for a big number of $n$, but I don't know how to define this in Mathematica. These are my questions: Find a pair of primes $(p,q)$ for every even integer $n$, ...
7
votes
4answers
392 views

How to make pairs of Young diagrams appear?

I have the following Young diagrams {{{0}, {2}}, {{0}, {1, 1}}, {{1}, {1}}, {{2}, {0}}, {{1, 1}, {0}}} where you can interpret each pair as following: For ...