Frequencies<T> class Null safety

Frequencies of discrete items.

Example

import 'package:calc/calc.dart';

void main() {
  // Two cats and two other animals
  final frequencies = Frequencies<String>.from([
    'dog',
    'cat',
    'rabbit',
    'cat',
  ]);

  final catPmf = frequencies.pmf('cat'); // --> 0.5
  print('Likelihood of cats based on the seen data: $catPmf');
}
Inheritance

Constructors

Frequencies.from(Iterable<T> iterable)
Calculates frequencies of discrete items. [...]
factory
Frequencies.fromMap(Map<T, num> masses)
Clones the map, normalizes the map values, and interprets the result as a distribution of observed values.
factory

Properties

entries Iterable<MapEntry<T, double>>
read-only
hashCode int
The hash code for this object. [...]
read-only, override
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
values Iterable<T>
Values in the distribution.
read-only

Methods

map<R>(R f(T value), {T reverse(R value)?}) DiscreteDistribution<R>
Maps the distribution with the given function. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
pmf(T value) double
Probability mass function (PMF) tells probability of specific event. [...]
override
sample({Random? random}) → T
Generates a random sample. [...]
override
sampleList(int length, {Random? random}) List<T>
Generates a list of N random samples. [...]
inherited
toMap() Map<T, double>
toString() String
A string representation of this object. [...]
override

Operators

operator ==(Object other) bool
The equality operator. [...]
override