All Projects → ndelvalle → array-smooth

ndelvalle / array-smooth

Licence: MIT license
Moving average smooth algorithm

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to array-smooth

Vanilla Tilt.js
A smooth 3D tilt javascript library.
Stars: ✭ 2,851 (+14155%)
Mutual labels:  smooth
universalSmoothScroll
A cross-browser smooth-scrolling API which supports multiple and interruptable scroll-animations on all DOM's elements, even at the same time!
Stars: ✭ 46 (+130%)
Mutual labels:  smooth
smooth
The set of smoothing functions used for time series analysis and in forecasting.
Stars: ✭ 78 (+290%)
Mutual labels:  smoothing
modape
MODIS Assimilation and Processing Engine
Stars: ✭ 19 (-5%)
Mutual labels:  smoothing
Interactive Data Editor
A Software to interactively edit data in a graphical manner
Stars: ✭ 35 (+75%)
Mutual labels:  smoothing
smooth-corners
CSS superellipse masks using the Houdini API
Stars: ✭ 133 (+565%)
Mutual labels:  smoothing
Snappyrecyclerview
An extension to RecyclerView which will snap to child Views to the specified anchor, START, CENTER or END.
Stars: ✭ 178 (+790%)
Mutual labels:  smooth
Basic-Image-Processing
Implementation of Basic Digital Image Processing Tasks in Python / OpenCV
Stars: ✭ 102 (+410%)
Mutual labels:  smoothing
ReactZooApp
ReactZooApp
Stars: ✭ 33 (+65%)
Mutual labels:  smooth
polatory
Fast, memory-efficient 3D spline interpolation and global kriging, via RBF (radial basis function) interpolation.
Stars: ✭ 82 (+310%)
Mutual labels:  smoothing
Streamator
A Spectator Specifically build for Content Creation and Streaming
Stars: ✭ 18 (-10%)
Mutual labels:  smoothing
gee whittaker
Non-parametric weighted Whittaker smoothing
Stars: ✭ 30 (+50%)
Mutual labels:  smoothing
discrete frechet
Compute the Fréchet distance between two polygonal curves in Euclidean space.
Stars: ✭ 68 (+240%)
Mutual labels:  smoothing
Moveto
A lightweight scroll animation javascript library without any dependency
Stars: ✭ 2,746 (+13630%)
Mutual labels:  smooth
scripts
Small, useful platform-agnostic scripts (mostly just for Linux) that don't justify having their own repo
Stars: ✭ 25 (+25%)
Mutual labels:  smooth
Vue Smooth Picker
🏄🏼 A SmoothPicker for Vue 2 (like native datetime picker of iOS)
Stars: ✭ 188 (+840%)
Mutual labels:  smooth
pico-lambda
pico sized functional library
Stars: ✭ 70 (+250%)
Mutual labels:  javascript-array
react-svg-pathline
React component for drawing SVG path through set of points, smoothing the corners
Stars: ✭ 42 (+110%)
Mutual labels:  smooth
undither
Smart filter to remove Floyd-Steinberg dithering from paletted images
Stars: ✭ 38 (+90%)
Mutual labels:  smoothing
interpolations
Lightweight Unity library for smoothing movements and value progressions in code (dragging, easing, tweening).
Stars: ✭ 29 (+45%)
Mutual labels:  smoothing

array-smooth

Codeship Status for ndelvalle/array-smooth Coverage Status dependencies Status devDependencies Status Codacy Badge code style: prettier

In smoothing, the data points of a signal are modified so individual points (presumably because of noise) are reduced, and points that are lower than the adjacent points are increased leading to a smoother signal. The algorithm used in this implementation is the moving average (rolling average or running average)

Install

$ npm install --save array-smooth
$ yarn add array-smooth

Use

const smooth = require('array-smooth')

const arr = [15, 2, 3, 14, 5, 6, 2, 8, 9, 10, 22, 3, 2, 11, 12]
const windowSize = 2
const arrSmoothed = smooth(arr, windowSize)

// arrSmoothed: [6.666666666666667, 8.5, 7.8, 6, 6, 7, 6, 7, 10.2, 10.4, 9.2, 9.6, 10, 7, 8.333333333333334]

API

smooth(array, windowSize, [getter], [setter])

array array

An array containing the values that we want to smooth, it can be an array of numbers or an array of objects defining a specific getter and / or setter

windowSize number

The smooth window option its a number that specifies the width of the moving average. It represents how many values to the right and left of the current index the algorithm will take in account when getting the sample to generate the smoothed value

getter(value) function

This function will receive the array value as an argument, it should return the attribute to smooth the array with. Is equivalent to calling array.map(getter)

Example:

const arr = [{ value: 15 }, { value: 2 }, { value: 3 }, { value: 14 }, { value: 5 }]

const getter = (item) => item.value
setter(value, smoothedValue) function

This function receives value and smoothedValue as arguments. The response will be the item that will populate the result array

Example:

const arr = [{ value: 15 }, { value: 2 }, { value: 3 }, { value: 14 }, { value: 5 }]

const getter = (item) => item.value
const setter = (item, itemSomoothed) => ({ value: item, valueSmoothed: itemSomoothed })

Playground

Edit array-smooth

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].