nrandom 1.0.4 copy "nrandom: ^1.0.4" to clipboard
nrandom: ^1.0.4 copied to clipboard

Index random generator, return a index with customizable probability.

nrandom #

Index random generator, return a index with customizable probability.

Ex: length = 5
1 2 3 4 5 => default probability = 100 / length = 20% each number
If choose 1
=> probability of number 1 will DECREASE A HALF (changeable) -> from 20% to 10%
=> 10% from number 1 will increase all the remaining 4 numbers
1    2      3      4      5
10%  22.5%  22.5%  22.5%  22.5%
Continue, next random is number 3
1       2       3       4       5
13.75%  26.25%  11.25%  26.25%  26.25%

Usage #

// Arrange
final int length = 5;
final NRandom nrandom = NRandom(length);

// Act
final int index = nrandom.getNextIndex();
3
likes
30
pub points
0%
popularity

Publisher

verified publishernhancv.com

Index random generator, return a index with customizable probability.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on nrandom