BlockMap
BlockMap[f,list,n]
applies f to non-overlapping sublists of length n in list.
BlockMap[f,list,n,d]
applies f to sublists with offset d in list.
BlockMap[f,list,{n1,n2,…},…]
applies f to blocks of size n1×n2×….
Examples
open allclose allBasic Examples (4)
Scope (7)
Apply a function to a ragged array:
Apply a function to blocks of size {2,1,2} of a rank-3 array:
Specify an offset {1,2} with a block size {2,2} to allow overlapping for rows but not for columns:
Skip elements by using an offset larger than the block size:
Incomplete sublists at the end are dropped:
The head need not be List:
BlockMap works with SparseArray objects:
Applications (5)
Compute successive differences of elements:
Compute a moving average with runs of 3 elements:
Compute a moving median of a matrix:
Compute a moving quantile for some data:
Smooth a simulated particle trajectory:
The underlying signal and simulated path with noise:
Smooth the trajectory using a moving TrimmedMean:
Properties & Relations (2)
BlockMap is effectively the same as using Map and Partition:
BlockMap need not construct all the sublists and requires less memory:
ListCorrelate[ker,list] effectively combines ker with a sliding block in list:
Use an offset of 1 in BlockMap to apply the function to overlapping segments the length of ker:
ListConvolve is similar except the kernel is reversed:
Text
Wolfram Research (2015), BlockMap, Wolfram Language function, https://reference.wolfram.com/language/ref/BlockMap.html.
CMS
Wolfram Language. 2015. "BlockMap." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/BlockMap.html.
APA
Wolfram Language. (2015). BlockMap. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BlockMap.html