dart_statistics 0.0.2
A dart library for statistics
Usage #
A simple usage example:
import 'package:dart_statistics/dart_statistics.dart';
void main() {
// We expect a fair die
final expected = <double>[2, 2, 2, 2, 2, 2];
// Looks pretty unfair...
final observed = <double>[6, 3, 3, 0, 0, 0];
// Reduction in degrees of freedom is 1, since knowing 5 categories determines the 6th
final reduction = 1;
var probability = chiSquaredTest(
observed,
expected,
degreesOfFreedomReduction: reduction,
).probability;
print(probability);
assert(probability == 0.010362);
// Gives 0.010362, which indicates that it's unlikely the die is fair
// However, something a little more likely
observed.clear();
observed.addAll([1, 2, 4, 4, 2, 1]);
probability = chiSquaredTest(
observed,
expected,
degreesOfFreedomReduction: reduction,
).probability;
print(probability);
assert(probability == 0.414881);
// Gives back 0.415881, which is indicates that they did come from the same distribution (by most statistical standards)
}
Features and bugs #
Please file feature requests and bugs on github, I will gladly accept pull requests and changes, this is not a library that I'm actively developing. If anyone would like to take over the library that is also fine.
0.0.1 #
 Initial version, created by Tim Whiting, borrowed heavily from javascript npm packages chisquaredtest, chisquared and gamma
0.0.2 #
 Changed optional parameter of degrees of freedom reduction to be 1, since a lot of applications will require the frequencies / probabilities to sum to one. And a reduction of 0 would cause an exception anyways
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
dart_statistics: ^0.0.2
2. Install it
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter pub get
Alternatively, your editor might support pub get
or flutter pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:dart_statistics/dart_statistics.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]

45

Health:
Code health derived from static analysis.
[more]

100

Maintenance:
Reflects how tidy and uptodate the package is.
[more]

90

Overall:
Weighted score of the above.
[more]

70

We analyzed this package on Mar 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
 Dart: 2.7.1
 pana: 0.13.6
Health suggestions
Format lib/src/chi_squared_test.dart
.
Run dartfmt
to format lib/src/chi_squared_test.dart
.
Maintenance suggestions
Package is prev0.1 release. (10 points)
While nothing is inherently wrong with versions of 0.0.*
, it might mean that the author is still experimenting with the general direction of the API.
Maintain an example.
None of the files in the package's example/
directory matches known example patterns.
Common filename patterns include main.dart
, example.dart
, and dart_statistics.dart
. Packages with multiple examples should provide example/README.md
.
For more information see the pub package layout conventions.