diff --git a/src/modules/n-arm-bandit/bandit.ts b/src/modules/n-arm-bandit/bandit.ts index e5f3fd8..2515cfd 100644 --- a/src/modules/n-arm-bandit/bandit.ts +++ b/src/modules/n-arm-bandit/bandit.ts @@ -2,12 +2,18 @@ export default { config: () => { return { - variance: Math.random() * 10, - base: Math.random() * 10 + ...genBaseStats() }; } } +function genBaseStats() { + return { + variance: Math.random() * 10, + base: Math.random() * 10 + } +} + function randomNormal(width: number = 1, offset: number = 0) { var u = 0, v = 0; while(u === 0) u = Math.random(); //Converting [0,1) to (0,1) @@ -22,8 +28,10 @@ export function pull() { export function getAverageReward() { const avg = this.config.base; - this.config.variance = Math.random() * 10; - this.config.base = Math.random() * 10; + this.config = { + ...this.config, + ...genBaseStats() + } console.log('slots real reward was: ' + avg); return avg; } \ No newline at end of file