Frequencies<T> class
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
-
- Object
- Distribution<
T> - DiscreteDistribution<
T> - Frequencies
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
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 nonexistent 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