如何在颤振中标准化[-1, 1]之间的数据

GIL*_*ILO 3 android normalization dart flutter

我想知道 flutter 中是否有内置的标准化功能。就像这样工作

List<int> array = [-105,24,66,-50,-49,2]

//Normalises to get numbers between -1 and 1
List<double> normalised = array.normalise(-1,1) 
Run Code Online (Sandbox Code Playgroud)

Mig*_*ivo 5

恐怕没有,但我已经手动制作了您要寻找的内容:

import 'dart:math';

List<int> array = [-105, 24, 66, -50, -49, 2];
final lower = array.reduce(min);
final upper = array.reduce(max);
final List<double> normalized = [];

array.forEach((element) => element < 0
    ? normalized.add(-(element / lower))
    : normalized.add(element / upper));

print(normalized);
Run Code Online (Sandbox Code Playgroud)