Linked Questions

63
votes
8answers
8k views

How to efficiently find positions of duplicates?

Is there an efficient way to find the positions of the duplicates in a list? I would like the positions grouped according to duplicated elements. For instance, given ...
25
votes
5answers
785 views

Partitioning a list when the cumulative sum exceeds 1

I have a long list of say 1 million Uniform(0,1) random numbers, such as: dat = {0.71, 0.685, 0.16, 0.82, 0.73, 0.44, 0.89, 0.02, 0.47, 0.65} I want to ...
9
votes
4answers
1k views

Index-based Array splitting

I have an array of arbitrary elements, say strings: testArray = {"String A", "String B", "String C", "String D", "String E"}; How can I split this into two ...
16
votes
2answers
290 views

3D Thinning algorithm in Mathematica

as far as I understood Thinning[] only works on 2D images thus far. Is there a library/piece of code that performs 3D Thinning in Mathematica? Max edit: I want ...
17
votes
1answer
360 views

Ordering function with recognition of duplicates

Fairly often I have a need to get the Ordering of an expression but with recognition of duplicates. For example: ...
5
votes
4answers
468 views

How to increase the speed of DeleteDuplicates on some selected columns?

I have a data1 with 4 columns and would like to remove the duplications by looking at the first 3 columns. Thus I used below code:- ...
8
votes
4answers
943 views

How to Gather a list with some elements considered unique

I have a list of the form: list={{0,...},{1,...},{1,...},{0,...},{3,...},{3,...},{0,...},{0,...},{5,...},{5,...},{5,...},{0,...},{5,...},{0,...},...} So when we ...
5
votes
3answers
180 views

How to calculating groupwise mean

I have a huge panel data with more than 2.5 million observations and more than 15000 groups. I want to calculate group-wise mean and I also need Id variable in my result. This is what I have done. <...
4
votes
4answers
146 views

Obtain all the (multinomial) subsets

I have a set, lets say: set = {1, 2, 3, 4, 5} I want to get all the possible subsets with 1, 2, and 2 elements. What I did was to generate all possible ...
5
votes
2answers
89 views

Looking up one additional array element increases runtime by three orders of magnitude

The Problem I have a list myList, which is a 487135 x 3 x 2 array of integers between -1000 and 1000. I want to be able to ...
2
votes
2answers
95 views

Subpartitioning elements of a list based on some h[ri] == h[rj] test

If we have a list of elements: list = {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12}; I'd like to further partition the elements into sets where, for some ...