summaryrefslogtreecommitdiff
path: root/logoot.js
diff options
context:
space:
mode:
Diffstat (limited to 'logoot.js')
-rw-r--r--logoot.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/logoot.js b/logoot.js
index bcd5f6d..c8c7c02 100644
--- a/logoot.js
+++ b/logoot.js
@@ -21,7 +21,7 @@ export default {
return [this.maxInt+1]
},
- between(a, b) {
+ between(a, b, scale=100) {
// Strip zeros and find common length
const aLength = this.lengthWithoutZeros(a)
const bLength = this.lengthWithoutZeros(b)
@@ -103,9 +103,14 @@ export default {
}
}
- // Finally, sample between the upper and
- // lower bounds
- out.push(Math.floor(Math.random() * (upperBound + 1 - lowerBound)) + lowerBound)
+ // Create a random number in [0,1] but bias it to be small,
+ // so that numbers tend to increase by a small amount.
+ let random = Math.random()
+ random = -Math.log(1-random)/scale
+ random = Math.min(random, 1)
+
+ // Finally, sample between the upper and lower bounds
+ out.push(Math.floor(random * (upperBound + 1 - lowerBound)) + lowerBound)
return out
},