NumPy and SciPy, in pure Dart

Scientific computing for Dart and Flutter

Arrays, linear algebra, polynomial fits, FFT, filters, statistics, distributions and root finding. One package that runs on the Dart VM, in Flutter apps and on the web.

dart pub add scidart

Dart VM · Flutter (Android, iOS, macOS, Windows, Linux) · Web

Try it here

The library runs in this page

This demo calls scidart compiled to JavaScript, the same code a Flutter web app ships. Change the tones and the window, and the FFT and the parabolic peak estimate update.

Read the Fourier transform guide

Loading the interactive demo…

Example

Familiar if you know SciPy

Every example on this site runs against the released library when the site is built. The output you see is real.

Normal distributionDensity, probabilities, quantiles and samples of a normal distribution, like scipy.stats.norm.
import 'dart:math' as math;

import 'package:scidart/numdart.dart';
import 'package:scidart/scidart.dart';

void main() {
  // adult height in cm
  var height = NormalDistribution(mean: 170, std: 8);

  print('density at 170: ${height.pdf(170)}');
  print('P(height < 180): ${height.cdf(180)}');
  print('P(height > 190): ${height.sf(190)}');
  print('95th percentile: ${height.ppf(0.95)}');
  print('central 95%: ${height.interval(0.95).toList()}');

  var s = height.sample(10000, random: math.Random(42));
  print(
      'sample mean: ${mean(s).toStringAsFixed(2)}, std: ${standardDeviation(s).toStringAsFixed(2)}');
}
Output
density at 170: 0.04986778505017909
P(height < 180): 0.8943502263331448
P(height > 190): 0.0062096653257761375
95th percentile: 183.1588290156118
central 95%: [154.32028812367957, 185.67971187632043]
sample mean: 169.93, std: 7.92

All examples

Modules

What is inside

NumDart package:scidart/numdart.dart

SciDart package:scidart/scidart.dart

Latest release

scidart 0.1.1

Fixes

  • randomArray2d(rows, columns) returns rows rows of columns values; it had rows and columns swapped
  • fft with n larger than the input appends the zeros at the end, like numpy.fft.fft; they were added at the start, which changed the phase of the result. rfft gets the same fix
  • toString of Array and Complex no longer starts with a line break, as their documentation shows. ArrayComplex prints on one line, and Array2d and Array3d print one row per line without trailing spaces

Docs

  • API documentation builds without warnings (unresolved references in doc comments)
  • The scidart.org site is rebuilt after each release

Full release notes