Files
sdk/pkg/front_end/tool/standard_deviation.dart
T
Johnni Winther 808fa4ca8b [cfe] Move tool/_fasta/ to tool/
Change-Id: I5b7348fb4adb4e7f4039c91d54d712c1eb131ecf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395002
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-11-18 07:49:01 +00:00

23 lines
763 B
Dart

// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math';
double average(List<double> elapsedTimes) {
return elapsedTimes.reduce((v, e) => v + e) / elapsedTimes.length;
}
double standardDeviation(double mean, List<double> elapsedTimes) {
double numerator = 0.0;
for (double elapseTime in elapsedTimes) {
numerator += (elapseTime - mean) * (elapseTime - mean);
}
double stdDev = sqrt(numerator / (elapsedTimes.length - 1));
return stdDev;
}
double standardDeviationOfTheMean(List<double> elapsedTimes, double stdDev) {
return stdDev / sqrt(elapsedTimes.length);
}