positiveDifference static method

double positiveDifference(
  1. List<double> current,
  2. List<double> previous
)

Computes the positive difference between two spectra, summing only the positive changes in magnitude across all frequency bins.

Implementation

static double positiveDifference(
  List<double> current,
  List<double> previous,
) {
  if (current.length != previous.length) {
    throw ArgumentError('Spectra must have the same length.');
  }

  double value = 0;

  for (int i = 0; i < current.length; i++) {
    final difference = current[i] - previous[i];

    if (difference > 0) {
      value += difference;
    }
  }

  return value;
}