# normal #

A simple library for working with the normal probability distribution.

## Usage #

A simple usage example:

``````import "package:normal/normal.dart";

main() {
// Probability density function.
print("\nNormal.pdf\n----------\n");
for (final x in List.generate(14, (i) => (i - 6) / 2)) {
final p = Normal.pdf(x);
print(
"\${x.toString().padLeft(4)} |\${" " * (p * 30).round()}:\${p.toStringAsFixed(4)}");
}

// Cumulative density function.
print("\nNormal.cdf\n----------\n");
for (final x in List.generate(14, (i) => (i - 6) / 2)) {
final p = Normal.cdf(x);
print(
"\${x.toString().padLeft(4)} |\${" " * (p * 40).round()}:\${p.toStringAsFixed(4)}");
}

// Quantile function.
print("\nNormal.inverseCdf\n-----------------\n");
for (final p in List.generate(9, (i) => (i + 1) * 0.1)) {
final x = Normal.inverseCdf(p);
}

// Generate random numbers.
print("\nNormal.generate\n---------------\n");
for (final x in Normal.generate(10, seed: 0)) {
}
}

``````

Output:

``````Normal.pdf
----------

-3.0 |:0.0044
-2.5 | :0.0175
-2.0 |  :0.0540
-1.5 |    :0.1295
-1.0 |       :0.2420
-0.5 |           :0.3521
0.0 |            :0.3989
0.5 |           :0.3521
1.0 |       :0.2420
1.5 |    :0.1295
2.0 |  :0.0540
2.5 | :0.0175
3.0 |:0.0044
3.5 |:0.0009

Normal.cdf
----------

-3.0 |:0.0013
-2.5 |:0.0062
-2.0 | :0.0228
-1.5 |   :0.0668
-1.0 |      :0.1587
-0.5 |            :0.3085
0.0 |                    :0.5000
0.5 |                            :0.6915
1.0 |                                  :0.8413
1.5 |                                     :0.9332
2.0 |                                       :0.9772
2.5 |                                        :0.9938
3.0 |                                        :0.9987
3.5 |                                        :0.9998

Normal.inverseCdf
-----------------

0.1     -1.2817
0.2     -0.8415
0.3     -0.5240
0.4     -0.2529
0.5     -0.0000
0.6      0.2529
0.7      0.5240
0.8      0.8415
0.9      1.2817

Normal.generate
---------------

0.4679
-0.4057
-0.2936
-1.2753
0.1079
-0.5593
0.2815
-0.1063
0.6585
0.7765
``````

## Features and bugs #

Thanks for your interest in normal. Please submit any issues you encounter.

## 0.5.0 #

• Initial version

example/normal_example.dart

``````import "package:normal/normal.dart";

main() {
// Probability density function.
print("\nNormal.pdf\n----------\n");
for (final x in List.generate(14, (i) => (i - 6) / 2)) {
final p = Normal.pdf(x);
print(
"\${x.toString().padLeft(4)} |\${" " * (p * 30).round()}:\${p.toStringAsFixed(4)}");
}

// Cumulative density function.
print("\nNormal.cdf\n----------\n");
for (final x in List.generate(14, (i) => (i - 6) / 2)) {
final p = Normal.cdf(x);
print(
"\${x.toString().padLeft(4)} |\${" " * (p * 40).round()}:\${p.toStringAsFixed(4)}");
}

// Quantile function.
print("\nNormal.inverseCdf\n-----------------\n");
for (final p in List.generate(9, (i) => (i + 1) * 0.1)) {
final x = Normal.quantile(p);
}

// Generate random numbers.
print("\nNormal.generate\n---------------\n");
for (final x in Normal.generate(10, seed: 0)) {
}
}
``````

## Use this package as a library

### 1. Depend on it

``````
dependencies:
normal: ^0.5.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:normal/normal.dart';
``````
 Popularity: Describes how popular the package is relative to other packages. [more] 52 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] 76

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

• Dart: 2.6.0
• pana: 0.12.21

#### Platforms

Detected platforms: Flutter, web, other

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

#### Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
pedantic ^1.0.0