Skip to content

Instantly share code, notes, and snippets.

@tomenden
Created December 25, 2017 09:23
Show Gist options
  • Save tomenden/8f6b79297dd249d34532046f07a163e5 to your computer and use it in GitHub Desktop.
Save tomenden/8f6b79297dd249d34532046f07a163e5 to your computer and use it in GitHub Desktop.
normalize values (feature scaling)
// https://en.wikipedia.org/wiki/Normalization_(statistics)#Examples
data = [
14,
15,
17,
22,
25,
28,
40,
40,
60
]
a = 14
14
b = 36
36
Xmax = 60
60
Xmin = 14
14
data.map(x => a + ((x - Xmin) * (b - a))/(Xmax - Xmin))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment