GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - antononcube/Raku-Data-Transformers: Raku package with algorithms for transforming and smoothing data.

BranchesTags
Open more actions menu

Latest commit

 

History

32 Commits
32 Commits

Folders and files

NameName
Last commit message
Last commit date
lib/Data
lib/Data
 
 
resources
resources
 
 
t
t
 
 
.gitignore
.gitignore
 
 
Changes
Changes
 
 
LICENSE
LICENSE
 
 
META6.json
META6.json
 
 
README-work.md
README-work.md
 
 
README.md
README.md
 
 

Repository files navigation

Data::Transformers

Raku package with algorithms for transforming and smoothing data. Provides the subs:

  • DONE accumulate
  • DONE array-pad
  • TODO array-filter
  • DONE center-array
  • TODO clip
  • TODO difference
  • TODO list-convolve
  • TODO list-correlate
  • TODO moving-average
  • TODO moving-map
  • TODO moving-median
  • DONE rescale
  • DONE standardize

Installation

From Zef ecosystem:

zef install Data::Tranformers

From GitHub:

zef install https://github.com/antononcube/Raku-Data-Tranformers.git

accumulate

Cumulative sums:

use Data::Transformers;

accumulate([3, 8, 4, 11, 9, 2]);
# [3 11 15 26 35 37]

Cumulative sums for a list of lists of numbers:

accumulate((1...10).rotor(2))
# [[1 2] [4 6] [9 12] [16 20] [25 30]]

Applications

Triangular numbers:

(1..10) ==> accumulate
# [1 3 6 10 15 21 28 36 45 55]

Random walk:

use Text::Plot;
use Data::Generators;

text-list-plot(accumulate(random-real([-1, 1], 100)))
# +---+---------+---------+----------+---------+----------+--+       
# |                                                          |       
# |                                          *****           |       
# |                                      * ***   ** *        |       
# +                                   ******       * **      +  10.00
# |                       **         **                ***   |       
# |                      ** **********                   *   |       
# |                  *****    *                              |       
# +              * ***                                       +   5.00
# |             ****                                         |       
# |           ***                                            |       
# |   ***    *                                               |       
# +   * *****                                                +   0.00
# |                                                          |       
# +---+---------+---------+----------+---------+----------+--+       
#     0.00      20.00     40.00      60.00     80.00      100.00

array-pad

Pad the edges with 0s:

array-pad([1,2,3], 1)
# [0 1 2 3 0]

Specify different padding on each side:

array-pad(1..3, [2, 4])
# [0 0 1 2 3 0 0 0 0]

Pad the edges of a matrix:

.say for array-pad([[1, 2], [3, 4]], 2)
# [0 0 0 0 0 0]
# [0 0 0 0 0 0]
# [0 0 1 2 0 0]
# [0 0 3 4 0 0]
# [0 0 0 0 0 0]
# [0 0 0 0 0 0]

Pad according to a named rule:

array-pad(1..3, 2, "Fixed")
# [1 1 1 2 3 3 3]

Pad only on the right:

array-pad(1..3, [0, 2])
# [1 2 3 0 0]

Remove elements from each edge of an array:

array-pad(1..10, -2)
# [3 4 5 6 7 8]

This is equivalent to dropping the first two elements:

array-pad([1, 2, 3, 4], [-2, 0]);
# [3 4]

This is equivalent to dropping the last two elements:

array-pad([1, 2, 3, 4], [0, -2]);
# [1 2]

Named rules

Pad by repeating periodically:

array-pad(1..6, 4, "Periodic")
# [3 4 5 6 1 2 3 4 5 6 1 2 3 4]
array-pad(1..3, 4, "Periodic")
# [3 1 2 3 1 2 3 1 2 3 1]

Pad with the reversal of the list:

array-pad(1..3, 4, "Reversed")
# [3 3 2 1 1 2 3 3 2 1 1]

Pad with the negative of the reversal:

array-pad(1..3, 4, "ReversedNegation")
# [3 -3 -2 -1 1 2 3 -3 -2 -1 1]

Pad by reflecting about the edge:

array-pad(1..3, 4, "Reflected")
# [1 2 3 2 1 2 3 2 1 2 3]

center-array

Create a list of length 5 with a single 1 at the center:

center-array(5)
# [0 0 1 0 0]

Create a list of length 5 with the specified element at the center:

center-array('x', 5)
# [0 0 x 0 0]

Place an element at the center of a 2D array:

.say for center-array('x', [5, 5])
# [0 0 0 0 0]
# [0 0 0 0 0]
# [0 0 x 0 0]
# [0 0 0 0 0]
# [0 0 0 0 0]

Center a list in a 2D array:

.say for center-array(1..3, [5, 5])
# [0 0 0 0 0]
# [0 0 0 0 0]
# [0 1 2 3 0]
# [0 0 0 0 0]
# [0 0 0 0 0]

The default padding is zero:

center-array([1, 2, 3], 6)
# [0 1 2 3 0 0]

rescale

Rescale to run from 0 to 1 over the range -10 to 10:

rescale(2.5, [-10, 10])
# 0.625
rescale(12.5, [-10, 10])
# 1.125
rescale(3, [-9, 7], [11, 28])
# 23.75

Complex number inputs:

rescale(1 + 2i, [0, 5])
# 0.2+0.4i
rescale(1 + 2i, [0, 1 + 1i])
# 1.5+0.5i

Rescale so that all the list elements run from 0 to 1:

rescale([-.7, .5, 1.2, 5.6, 1.8])
# (0 0.190476 0.301587 1 0.396825)

clip

Not implemented yet.


standardize

standardize(@data) shifts and rescales the elements of @data to have zero mean and unit sample variance.

standardize(@data, $center, $scale) shifts by $center and scales by $scale. The arguments $center and $scale can be numbers, callables, or Whatever.

Compute standard scores for data:

standardize([6.5, 3.8, 6.6, 5.7, 6.0, 6.4, 5.3])
# [0.8177071028391707 -2.1543437132493533 0.9277830589905974 -0.06290054637224389 0.2673273220820366 0.7076311466877439 -0.5032043709779511]

About

Raku package with algorithms for transforming and smoothing data.

raku.land/zef:antononcube/Data::Transformers

Topics

array-manipulationsclippingconvolutioncorrelationdatadata-toolsdata-transformationmoving-averagerakurakulangrescalerescaling

Resources

Readme
Artistic-2.0 license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.