stats_probability_utils 0.9.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new61

Stats & Probability Utils #

It's a dart library focused on solving statistical problems, includes functions to get Descriptive Stats for grouped and ungrouped data such as the following:

  • Measures of Central Tendency -- Mode -- Mean (arithmetic, geometric, pondered) -- Median -- Max,Min
  • Measures of Dispersion -- Range -- Variance (sample, population) -- Standard Deviation (sample, population)
  • Measures of Position -- quartiles
  • Frecuency Table

Install dependencies #

  1. Run pub get to install dependencies.

Example #

// Instance Object
Stats stats = Stats([1, 1, 1, 2, 3, 4, 2, 5, 3, 6, 5, 4, 6, 5, 4, 6, 7, 3, 6, 7]);

// -------------------------------
// -- UnGrouped Data
// ------------------------------
// Measures of central Tendency
print(stats.min); // 1
print(stats.max); // 7
print(stats.summation); // 81
// [arithmeticMean, geometricMean, ponderedMean]
print(stats.getMean()); // [4.05, 3.44, 4.05]
// [ [element, frecuency], ... ]
print(stats.getFrecuencies()); // [[1, 3], [2, 2], [3, 3], [4, 3], [5, 3], [6, 4], [7, 2]]
print(stats.getMode()); // [6]
print(stats.getMedian()); // 4.0

// Measures of Dispersion
// [sample, population]
print(stats.getVariance()); // [3.94, 3.74]
// [sample, population]
print(stats.getStandardDeviation()); // [1.98,1.93]
print(stats.getRange()); // 6

// -------------------------------
// -- Grouped Data
// ------------------------------
// Measures of central Tendency
print(stats.getMeanOfGroupedData()); // 4.12
print(stats.getMedianOfGroupedData()); // 4.2
print(stats.getModeOfGroupedData()); // 6.2

// Frecuency Table
print(stats.getIntervalsBySturgesRule()); // 5
print(stats.getAmplitude()); // 1.2
Map<String, dynamic> groupedClassLimit;
List<Map<String, dynamic>> groupedTable = stats.getGroupedFrecuencyMap();

for (groupedClassLimit in groupedTable) {
print('Lower class limit: ${ groupedClassLimit['lowerClassLimit'] }');
print('Upper class limit: ${ groupedClassLimit['upperClassLimit'] }');
print('Mid point (Xi): ${ groupedClassLimit['midpoint'] }');
print('Absolute frecuency (Fi): ${ groupedClassLimit['absoluteFrecuency'] }');
print('Accumulated Relative frecuency (Fr): ${ groupedClassLimit['accumulatedRelativeFrecuency'] }');
print('Accumulated frecuency (F): ${ groupedClassLimit['accumulatedFrecuency'] }');
print('XiFi: ${ groupedClassLimit['XiFi'] }');
}

// Measures of Dispersion
// [sample, population]
print(stats.getVarianceGrouped()); [3.77, 3.58]
print(stats.getStandardDeviationGrouped()); // [1.94, 1.89]

// Measures of Position
// [q1,q2,q3]
print(stats.getQuartiles()); [2.5,4.0,6.0]

License #

GNU General Public License v3.0

Open source licenses #

Dart Decimals #

Copyright (c) 2013, Alexandre Ardhuin

https://github.com/a14n/dart-decimal

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

0.9.1 #

  • The limit class precision for decimal values was fixed
  • The frequency in grouped data was fixed
  • The unit tests for the library were update

0.9.0+2 #

  • The unit tests for the library were added
  • The stats class was fixed to handle the base case of zero and one element

0.9.0+1 #

  • Static analyzer was added
  • Dart files have been modified
  • AUTHORS file was added

0.9.0 #

  • Stats
    • Now has a type argument <T>
    • Measures of central Tendency
    • Measures of Dispersion
    • Measures of position (quartiles)
    • Frequency Table
  • Require Dart SDK >=2.7.0 <3.0.0.

example/example.dart

import 'package:stats_probability_utils/stats_probability_utils.dart';
void main() {
  final stats = Stats(
    [2, 1, 4, 3, 2, 2, 6, 8, 10, 9]
  );

  print(stats.sortedList);
  print(stats.min);
  print(stats.max);
  print(stats.summation);
  print(stats.getMean());
  print(stats.getFrecuencies());
  print(stats.getMode());
  print(stats.getMedian());

  print('-- Disperions measure --');
  print(stats.getVariance());
  print(stats.getStandardDeviation());
  print(stats.getRange());

  print('--grouped data--');
  print(stats.getIntervalsBySturgesRule());
  print(stats.getAmplitude());
  print('-- Grouped frecuency table --\n\n');
  Map<String, dynamic> groupedClassLimit;
  final groupedTable = stats.getGroupedFrecuencyMap();
  for (groupedClassLimit in groupedTable) {
    print('------------------');
    print('  Lower class limit: ${ groupedClassLimit['lowerClassLimit'] }');
    print('  Upper class limit: ${ groupedClassLimit['upperClassLimit'] }');
    print('  Mid point (Xi): ${ groupedClassLimit['midpoint'] }');
    print('  Absolute frecuency (Fi): ${ groupedClassLimit
      ['absoluteFrecuency'] }');
    print('  Accumulated Relative frecuency (Fr): ${ groupedClassLimit
      ['accumulatedRelativeFrecuency'] }');
    print('  Accumulated frecuency (F): ${ groupedClassLimit
      ['accumulatedFrecuency'] }');
    print('  XiFi: ${ groupedClassLimit
      ['XiFi'] }');
    print('------------------\n\n');
  }
  
  print('------------------\n\n');

  print(stats.getMeanOfGroupedData());
  print(stats.getMedianOfGroupedData());
  print(stats.getModeOfGroupedData());

  print('-- measures of disp for grouped data ---');
  print(stats.getVarianceGrouped());
  print(stats.getStandardDeviationGrouped());
  print(stats.getQuartiles());
}

Use this package as a library

1. Depend on it

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


dependencies:
  stats_probability_utils: ^0.9.1

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

We analyzed this package on May 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
decimal ^0.3.0 0.3.5
Transitive dependencies
rational 0.3.8
Dev dependencies
pedantic ^1.9.0
test ^1.14.3