38
votes
Accepted
28
votes
Accepted
Performance of Select
res1 = Select[coordinates, #[[1]] > 6 && #[[1]] < 7 &]; //
AbsoluteTiming // First
6.997629
...
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 ...
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:
...
22
votes
22
votes
Accepted
How to construct a list of lengths efficiently
You can use the usual UnitStep + Total tricks:
...
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 ...
21
votes
Find duplicates in list of InfiniteLine
DeleteDuplicates[lines, RegionWithin]
{InfiniteLine[{{0, 0}, {1, 0}}], InfiniteLine[{{0, 1}, {1, 0}}]}
Also
...
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 ...
21
votes
Accepted
Removing outliers from data
You could take a look at the built-in functions FindAnomalies and DeleteAnomalies.
We can use ...
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 ...
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. ...
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}
...
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 ...
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]
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. ...
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:
...
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 ...
17
votes
Accepted
17
votes
Accepted
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 ...
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]]
...
16
votes
Accepted
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 ...
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}} *)
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 ...
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:
...
15
votes
Accepted
Writing Faster Mathematica Code - Sow and Reap?
Here's a million points processed in half a second:
...
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 ...
15
votes
How to construct a list of lengths efficiently
BinCounts and Accumulate combination is faster than all the methods posted so far:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
filtering × 762list-manipulation × 407
pattern-matching × 75
performance-tuning × 47
dataset × 45
signal-processing × 43
data × 32
functions × 28
associations × 27
string-manipulation × 26
matrix × 24
image-processing × 21
conditional × 18
plotting × 15
replacement × 13
function-construction × 11
image × 11
date-and-time × 10
curated-data × 9
smoothing × 9
equation-solving × 8
expression-manipulation × 8
sorting × 8
probability-or-statistics × 7
import × 7