RandomGenerator class

Random number generator with various distributions.

Constructors

RandomGenerator([int? seed])
Creates a random generator with an optional seed.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

autocorrelatedNoise(int count, double correlation, {double stdDev = 1}) List<double>
Generates autocorrelated noise.
beta(double alpha, double betaParam) double
Generates a random value from a beta distribution.
binomial(int n, double p) int
Generates a random value from a binomial distribution.
boolean([double probability = 0.5]) bool
Generates a random boolean with the given probability of being true.
brownianMotion(int steps, {double start = 100, double mu = 0.0001, double sigma = 0.02, double dt = 1}) List<double>
Generates Brownian motion (geometric random walk).
choice<T>(List<T> items) → T
Selects a random element from a list.
exponential(double lambda) double
Generates a random value from an exponential distribution.
gamma(double shape, [double scale = 1.0]) double
Generates a random value from a gamma distribution.
logNormal(double mean, double stdDev) double
Generates a random value from a log-normal distribution.
normal(double mean, double stdDev) double
Generates a random value from a normal (Gaussian) distribution.
normalList(int count, double mean, double stdDev) List<double>
Generates a list of random values from a normal distribution.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pareto(double alpha, [double xMin = 1.0]) double
Generates a random value from a Pareto distribution.
poisson(double lambda) int
Generates a random value from a Poisson distribution.
randomColor({int? alpha}) int
Generates a random color.
randomWalk(int steps, {double start = 0, double stepSize = 1}) List<double>
Generates a random walk.
randomWalkWithDrift(int steps, {double start = 0, double drift = 0, double volatility = 1}) List<double>
Generates a random walk with drift.
sample<T>(List<T> items, int n) List<T>
Samples n items from a list without replacement.
shuffle<T>(List<T> items) List<T>
Shuffles a list in place and returns it.
toString() String
A string representation of this object.
inherited
triangular(double min, double max, double mode) double
Generates a random value from a triangular distribution.
uniform(double min, double max) double
Generates a random double between min and max.
uniformInt(int min, int max) int
Generates a random integer between min (inclusive) and max (exclusive).
uniformList(int count, double min, double max) List<double>
Generates a list of random values from a uniform distribution.
uuid() String
Generates a random UUID.
weibull(double shape, double scale) double
Generates a random value from a Weibull distribution.
weightedChoice<T>(List<T> items, List<double> weights) → T
Selects a random element from a list with weights.

Operators

operator ==(Object other) bool
The equality operator.
inherited