CreditChannelActivity.seededRandom constructor
Creates deterministic pseudo-random pool-attributed activity.
activeProbability determines whether a debit and return are emitted on
an individual cycle. A selected debit and return may target distinct
pools, allowing the generated stream to stress aggregate accounting.
Implementation
factory CreditChannelActivity.seededRandom(
{required int seed,
required int poolCount,
required double activeProbability}) {
if (poolCount < 1) {
throw ArgumentError.value(poolCount, 'poolCount', 'Must be positive.');
}
if (activeProbability < 0 || activeProbability > 1) {
throw ArgumentError.value(activeProbability, 'activeProbability',
'Must be between zero and one.');
}
return CreditChannelActivity._((cycle) {
final debitPool = _randomUnit(seed, cycle * 3) < activeProbability
? _randomPool(seed, cycle * 3 + 1, poolCount)
: null;
final returnPool = _randomUnit(seed, cycle * 3 + 2) < activeProbability
? _randomPool(seed, cycle * 3 + 3, poolCount)
: null;
return CreditChannelActivityEvent(
debitPool: debitPool, returnPool: returnPool);
}, 'seededRandom($seed,$poolCount,$activeProbability)');
}