Skip to content

Commit 056e295

Browse files
committed
Updated example.
1 parent e90e80f commit 056e295

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ as a dependency in your `pubspec.yaml` file.
2424
To access sample statistics use the class [`Stats`][Stats].
2525
It calculates sample statistics in a lazy fashion and caches results
2626
to avoid expensive calculations if the
27-
same quantity is accessed repeatedly. If the random sample changes
28-
use the method `updateCache()` to recalculate the sample statistics.
27+
same quantity is accessed repeatedly. Data points can be added using the
28+
method `addDataPoints()`. A call to `addDataPoint` triggers a call to
29+
`updateCache()` to recalculate the sample statistics.
30+
31+
To remove outliers use the method `removeOutliers`.
2932

3033
```Dart
3134
import 'package:sample_statistics/sample_statistics.dart'
@@ -49,29 +52,30 @@ use the method `updateCache()` to recalculate the sample statistics.
4952
final outliers = sample.removeOutliers();
5053
print('outliers: $outliers');
5154
print('sample with outliers removed: $sample');
52-
53-
// Update statistics after sample has changed:
54-
stats.updateCache();
55+
stats.addDataPoints([-2, 7]);
56+
print('Sample with additional data points: ${stats.sample}');
57+
print('Sorted sample: ${stats.sortedSample}');
5558
}
5659
```
5760

5861
<details> <summary> Click to show console output. </summary>
5962

6063
```Console
6164
$ dart sample_statistics_example.dart
62-
63-
Running sample_statistic_example.dart ...
65+
Running sample_statistics_example.dart ...
6466
Sample: [-10, 0, 1, 2, 3, 4, 5, 6, 20]
6567
min: -10
6668
max: 20
6769
mean: 3.4444444444444446
6870
median: 3
6971
first quartile: 1
7072
third quartile: 5
71-
interquartile range:4
73+
inter-quartile-range:4
7274
standard deviation: 7.779960011322538
7375
outliers:[-10, 20]
74-
sample with outliers removed: [0, 1, 2, 3, 4, 5, 6]
76+
Sample without outliers: [0, 1, 2, 3, 4, 5, 6]
77+
Sample with additional data points: [0, 1, 2, 3, 4, 5, 6, -2, 7]
78+
Sorted sample: [-2, 0, 1, 2, 3, 4, 5, 6, 7]
7579

7680
```
7781
</details>

0 commit comments

Comments
 (0)