nrandom 1.0.4

Flutter Android iOS web

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();
1
likes
100
pub points
11%
popularity

Index random generator, return a index with customizable probability.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

nhancv92@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on nrandom