NumDart
Statistics
Mean, median, mode, variance and standard deviation of a sample.
Like numpy.mean, numpy.median, scipy.stats.mode
import 'package:scidart/numdart.dart';
void main() {
var a = Array([2, 4, 4, 4, 5, 5, 7, 9]);
print('mean: ${mean(a)}');
print('median: ${median(a)}');
print('mode: ${mode(a)}');
print('multimode: ${multimode(Array([1, 1, 2, 2, 3])).toList()}');
print('variance: ${variance(a)}');
print('standard deviation: ${standardDeviation(a)}');
}
Output
mean: 5.0 median: 4.5 mode: 4.0 multimode: [1.0, 2.0] variance: 4.571428571428571 standard deviation: 2.138089935299395
varianceandstandardDeviationuse the sample formula, dividing byn - 1. This matchesnumpy.var(a, ddof=1), not the NumPy default.mediandoes not change the order of the input.modereturns the first of the most frequent values, in the order they appear;multimodereturns all of them in that order.
For probability distributions, see Normal distribution.
Loading the interactive demo…