38 votes
Accepted

Remove noise from data

You could try BilateralFilter: ...
Niki Estner's user avatar
  • 35.8k
28 votes
Accepted

Performance of Select

res1 = Select[coordinates, #[[1]] > 6 && #[[1]] < 7 &]; // AbsoluteTiming // First 6.997629 ...
kglr's user avatar
  • 363k
23 votes
Accepted

How to remove outliers from data

I will give you two similar methods. But, I will rewrite one of the comments above just to make sure it is read. You've been given some fine answers, but be absolutely sure that removing the ...
lalmei's user avatar
  • 3,294
22 votes

How do I delete all items that occur more than once?

Here is a test list: lst = {{1, 2}, {1, 2}, {3, 4}, {5, 6}, {5, 6}, {7, 8}} Here is one way then: ...
Leonid Shifrin's user avatar
22 votes

Performance of Select

Slightly faster than @kglr's solution is to use Clip: ...
Carl Woll's user avatar
  • 127k
22 votes
Accepted

How to construct a list of lengths efficiently

You can use the usual UnitStep + Total tricks: ...
Carl Woll's user avatar
  • 127k
21 votes
Accepted

Finding outliers in 2D and 3D numerical data

The question title poses a good question, although the question formulation is somewhat specialized and misplaced (as mentioned in a comment). This answer provides data and a method description ...
Anton Antonov's user avatar
21 votes

Find duplicates in list of InfiniteLine

DeleteDuplicates[lines, RegionWithin] {InfiniteLine[{{0, 0}, {1, 0}}], InfiniteLine[{{0, 1}, {1, 0}}]} Also ...
kglr's user avatar
  • 363k
21 votes
Accepted

Deleting duplicates after n-occurrences

I think you'll find this faster: dd[list_, n_] := Module[{pi = Flatten[Values[PositionIndex[list][[All, ;; UpTo@n]]]]}, list[[Sort@pi]]]; Using ...
ciao's user avatar
  • 25.4k
21 votes
Accepted

Removing outliers from data

You could take a look at the built-in functions FindAnomalies and DeleteAnomalies. We can use ...
Carl Lange's user avatar
  • 12.9k
20 votes

Remove noise from data

I would suggest using a median filter with small radius to eliminate the large spikes, then a mean filter to smooth the remaining signal. @Xavier essentially combines these two filters by using ...
KennyColnago's user avatar
20 votes

Deleting sublists from lists

ReplaceRepeated is fine for short lists but it will get very slow if the list is long, because it starts over from the beginning of the list after each replacement. ...
Mr.Wizard's user avatar
  • 267k
19 votes
Accepted

Deleting sublists from lists

Try testList //. {a___, aa_Symbol, _Integer, bb_Symbol, b___} :> {a, aa, bb, b} {a, b, c, 4, 5, d, e, f, g, 4} ...
jjc385's user avatar
  • 3,403
18 votes
Accepted

How to find all the positions of max value of a list efficiently?

A fast uncompiled alternative without pattern matching is to use the NonzeroPositions property of SparseArray, as long as you're ...
C. E.'s user avatar
  • 69.5k
18 votes

How to find all the positions of max value of a list efficiently?

For a 1D list you can also use Pick[Range@Length@list, list, Max@list]
Simon Woods's user avatar
  • 84.3k
18 votes
Accepted

Is it possible to Parallelize Select?

Time increases enormously with ParallelMap, because rlp = Partition[rl, 4]; produces 2500000 sublists of four elements each. ...
bbgodfrey's user avatar
  • 59.9k
18 votes

Deleting sublists from lists

Mr.Wizard inspired me to improve. While his recursive approach is elegant, the problem clearly can be done linearly. Indeed: ...
jjc385's user avatar
  • 3,403
17 votes

Why the BandpassFilter is different than applying LowpassFilter then HighpassFilter

Original Answer A good question to ask is: are these image processing filters or signal processing filters? If we take a signal processing viewpoint then it is useful to look at the impulse response ...
Hugh's user avatar
  • 15.7k
17 votes
Accepted

How to get cell boundaries in the image?

...
corey979's user avatar
  • 23.5k
17 votes
Accepted

Delete redundant {x,y} pairs

...
kglr's user avatar
  • 363k
17 votes

How can I code a "smart" version of Chop?

We can turn to unsupervised machine learning in the form of clustering algorithms to try to automate this intuition. Here are a few different results using ...
C. E.'s user avatar
  • 69.5k
16 votes

Finding the two pairs in a list of pairs that minimize and maximize a given function

list = {{1, 2}, {5, 3}, {9, 2}} func = 2*#[[1]] + #[[2]] &; Through[{MinimalBy[func], MaximalBy[func]}[list]] ...
Karsten 7.'s user avatar
  • 27.3k
16 votes
Accepted

Ordered RandomSample

Avoiding Sort makes it a bit faster ...
Coolwater's user avatar
  • 19.7k
16 votes
Accepted

Most efficient numerical selectBetween

Varying samples (Updated to include internal function) For varying samples, I think the best non-compiled method is to use Pick as you did. You can speed up the ...
Carl Woll's user avatar
  • 127k
16 votes
Accepted

Given a list of integers, find the largest sum of a contiguous subsequence

f[l_] := Module[{sl = Flatten@MaximalBy[Subsequences[l], Total]}, {Total[sl], sl}] f[{1, 2, 3, 4, 5, -1, 7, -4, -2}] (* {21, {1, 2, 3, 4, 5, -1, 7}} *)
bbgodfrey's user avatar
  • 59.9k
15 votes

Easiest/most efficient way to delete duplicates from one list at the positions of another?

You can accomplish this using DeleteDuplicatesBy, by first taking your two input lists and making a matrix out of them, and then deleting the rows where the last ...
Jason B.'s user avatar
  • 66.3k
15 votes

How do I delete all items that occur more than once?

Counting the times each element appears and then selecting all the elements that appear only once: ...
C. E.'s user avatar
  • 69.5k
15 votes
Accepted

Writing Faster Mathematica Code - Sow and Reap?

Here's a million points processed in half a second: ...
Michael E2's user avatar
  • 228k
15 votes

Solving chess bishop problem

Mathematica's FindIndependentVertexSet can find maximal independent set (size 14 =2n-2) by default. The following finds "12". I have not explored symmetries as I am ...
ubpdqn's user avatar
  • 56.5k
15 votes

How to construct a list of lengths efficiently

BinCounts and Accumulate combination is faster than all the methods posted so far: ...
kglr's user avatar
  • 363k

Only top scored, non community-wiki answers of a minimum length are eligible