diff options
author | theia | 2022-09-20 11:58:20 -0400 |
---|---|---|
committer | theia | 2022-09-20 11:58:20 -0400 |
commit | ce8d06656673984625a0a9626b39efc2137290e6 (patch) | |
tree | efe2d8e847f9f59b1ccec8092c2c08c413874d21 | |
parent | c3f16ab54bbe952a658b17558fca8115ed515ae1 (diff) |
anonymized and biased logoot
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | logoot.js | 13 |
2 files changed, 12 insertions, 7 deletions
@@ -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() @@ -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 }, |