README-work
Data::Transformers
Raku package with algorithms for transforming and smoothing data. Provides the subs:
DONE
accumulateDONE
array-padTODO
array-filterDONE
center-arrayTODO
clipTODO
differenceTODO
list-convolveTODO
list-correlateTODO
moving-averageTODO
moving-mapTODO
moving-medianDONE
rescaleTODO
standardize
Installation
From Zef ecosystem:
zef install Data::TranformersFrom GitHub:
zef install https://github.com/antononcube/Raku-Data-Tranformers.gitaccumulate
Cumulative sums:
use Data::Transformers;
accumulate([3, 8, 4, 11, 9, 2]);Cumulative sums for a list of lists of numbers:
accumulate((1...10).rotor(2))Applications
Triangular numbers:
(1..10) ==> accumulateRandom walk:
use Text::Plot;
use Data::Generators;
text-list-plot(accumulate(random-real([-1, 1], 100)))array-pad
Pad the edges with 0s:
array-pad([1,2,3], 1)Specify different padding on each side:
array-pad(1..3, [2, 4])Pad the edges of a matrix:
.say for array-pad([[1, 2], [3, 4]], 2)Pad according to a named rule:
array-pad(1..3, 2, "Fixed")Pad only on the right:
array-pad(1..3, [0, 2])Remove elements from each edge of an array:
array-pad(1..10, -2)This is equivalent to dropping the first two elements:
array-pad([1, 2, 3, 4], [-2, 0]);This is equivalent to dropping the last two elements:
array-pad([1, 2, 3, 4], [0, -2]);Named rules
Pad by repeating periodically:
array-pad(1..6, 4, "Periodic")array-pad(1..3, 4, "Periodic")Pad with the reversal of the list:
array-pad(1..3, 4, "Reversed")Pad with the negative of the reversal:
array-pad(1..3, 4, "ReversedNegation")Pad by reflecting about the edge:
array-pad(1..3, 4, "Reflected")center-array
Create a list of length 5 with a single 1 at the center:
center-array(5)Create a list of length 5 with the specified element at the center:
center-array('x', 5)Place an element at the center of a 2D array:
.say for center-array('x', [5, 5])Center a list in a 2D array:
.say for center-array(1..3, [5, 5])The default padding is zero:
center-array([1, 2, 3], 6)rescale
Rescale to run from 0 to 1 over the range -10 to 10:
rescale(2.5, [-10, 10])rescale(12.5, [-10, 10])rescale(3, [-9, 7], [11, 28])Complex number inputs:
rescale(1 + 2i, [0, 5])rescale(1 + 2i, [0, 1 + 1i])Rescale so that all the list elements run from 0 to 1:
rescale([-.7, .5, 1.2, 5.6, 1.8])clip
Not implemented yet.