From 0b6af85a818fa3c2a8dd8d78ccc29aa099dc40e8 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 21 Sep 2022 12:46:08 -0400 Subject: anonymized and biased logoot --- README.md | 6 +++--- logoot.js | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4c27ffa..bf80fd5 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Graffiti for Vanilla Javascript -This is the base Javascript library that interfaces with the [Graffiti server](https://github.com/csail-graffiti/server). -We recommend not using this vanilla library itself but instead using framework plugins that are built on top of it like the [Graffiti plugin for Vue.JS](https://github.com/csail-graffiti/graffiti-x-vue). +This is the base Javascript library that interfaces with the [Graffiti server](https://github.com/digital-graffiti/server). +We recommend not using this vanilla library itself but instead using framework plugins that are built on top of it like the [Graffiti plugin for Vue.JS](https://github.com/digital-graffiti/graffiti-x-vue). Example usage: ```javascript -import Graffiti from "https://csail-graffiti.github.io/graffiti-x-js/graffiti.js" +import Graffiti from "https://digital-graffiti.github.io/graffiti-x-js/graffiti.js" // You can initialize a connection to the graffiti server const graffiti = Graffiti() 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 }, -- cgit v1.2.3-70-g09d2