sampling 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

Dart library for sampling items #

Various algorithms for selection of a subset (a statistical sample) of individuals from within a statistical population to estimate characteristics of the whole population. This can be useful for tracking and sampling a stream of values.

Current algorithms:

  • latest N item
  • reservoir sampling (fair random sampling)

It can also track basic statistics of integer populations.

Usage #

A simple usage example:

final sampler = new ReservoirSampler(25, random: new Random.secure());
sampler.addAll(new List.generate(10000, (i) => i));
print(sampler.getSample());

1.0.2 #

  • Updated README.md

1.0.1 #

  • Dart 2 support.

1.0.0 #

  • Initial version.

example/sampling_example.dart

import 'dart:math';

import 'package:sampling/sampling.dart';

void main() {
  final sampler = new ReservoirSampler(25, random: new Random.secure());
  sampler.addAll(new List.generate(10000, (i) => i));
  print(sampler.getSample());
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  sampling: ^1.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:sampling/sampling.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Dec 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:sampling/sampling.dart.

Health suggestions

Fix lib/src/latest.dart. (-0.50 points)

Analysis of lib/src/latest.dart reported 1 hint:

line 8 col 27: Unnecessary new keyword.

Fix lib/src/reservoir.dart. (-0.50 points)

Analysis of lib/src/reservoir.dart reported 1 hint:

line 15 col 29: Unnecessary new keyword.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.3.0