@mark1russell7/rigor-generators 0.1.12 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { Random } from "./random.js";
2
1
  import { DistributionSpec } from "./distributions.js";
2
+ import { Random } from "./random.js";
3
3
  /** One dimension of an input family. */
4
4
  export interface Dimension {
5
5
  /** The name of the dimension. It is a key of each point. */
package/build/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Random, Source, deriveSeed, fnv1a32, mulberry32, random, randomOf, seedOf, seedsFrom, stablePick } from "./random.js";
2
1
  import { DistributionSpec, Param, dependsOnLibm, sampler } from "./distributions.js";
3
2
  import { normalCdf, normalQuantile } from "./normal.js";
4
3
  import { Distribution, betaCdf, distributionOf } from "./quantiles.js";
5
4
  import { Dimension, InputFamily, Point, SaltelliDesign, familyMap, familyPoints, latinHypercube, randomDesign, saltelliDesign, stratifiedDesign } from "./designs.js";
6
5
  import { CanonicalOptions, Sha256Options, canonicalHash, canonicalJson, sha256Hex } from "./hash.js";
7
6
  import { DIAGRAM_BOX_AREA, GIT_BLOB_BYTES, RECORDED_TABLES, RecordedTable, recordedSpec } from "./recorded.js";
7
+ import { Random, Source, deriveSeed, fnv1a32, mulberry32, random, randomOf, seedOf, seedsFrom, stablePick } from "./random.js";
8
8
  export { type CanonicalOptions, DIAGRAM_BOX_AREA, type Dimension, type Distribution, type DistributionSpec, GIT_BLOB_BYTES, type InputFamily, type Param, type Point, RECORDED_TABLES, type Random, type RecordedTable, type SaltelliDesign, type Sha256Options, type Source, betaCdf, canonicalHash, canonicalJson, dependsOnLibm, deriveSeed, distributionOf, familyMap, familyPoints, fnv1a32, latinHypercube, mulberry32, normalCdf, normalQuantile, random, randomDesign, randomOf, recordedSpec, saltelliDesign, sampler, seedOf, seedsFrom, sha256Hex, stablePick, stratifiedDesign };
@@ -1,5 +1,5 @@
1
- import { Random } from "./random.js";
2
1
  import { DistributionSpec } from "./distributions.js";
2
+ import { Random } from "./random.js";
3
3
  /** One point of a family: its parameters are fixed. */
4
4
  export interface Distribution {
5
5
  /** The family of the point. */
package/build/random.d.ts CHANGED
@@ -12,11 +12,12 @@ export declare function mulberry32(seed: number): Source;
12
12
  /**
13
13
  * The FNV-1a hash of 32 bits of a string. The option `input` selects the units that the hash reads:
14
14
  *
15
- * - `"utf8"` (the default): the UTF-8 bytes from `TextEncoder`. A lone surrogate becomes the bytes of U+FFFD.
15
+ * - `"utf8"` (the default): the UTF-8 bytes, equal to the bytes of `TextEncoder`. A lone surrogate becomes the bytes of U+FFFD.
16
16
  * - `"utf16"`: the UTF-16 code units of the string, one unit for each step, from `charCodeAt`.
17
17
  * - `"wtf8"`: the UTF-8 bytes of each code point. A lone surrogate becomes its own 3 bytes (WTF-8).
18
18
  *
19
- * For a string without a lone surrogate, `"utf8"` and `"wtf8"` give the same hash.
19
+ * For a string without a lone surrogate, `"utf8"` and `"wtf8"` give the same hash. The function uses no API of Node or
20
+ * of the browser, so the hash is the same on each platform.
20
21
  */
21
22
  export declare function fnv1a32(text: string, options?: {
22
23
  readonly input?: "utf8" | "utf16" | "wtf8";
@@ -1 +1 @@
1
- {"version":3,"file":"random.d.ts","names":[],"sources":["../src/random.ts"],"mappings":";;;;;;;;YASY;;wBAGI,WAAW,eAAe;;;;;;;;;;wBAsB1B,QAAQ,cAAc;WAAqB;;;wBAiC3C,OAAO;;wBAOP,WAAW,cAAc;;;;;;;;;;wBAazB,WAAW,GAAG,cAAc,gBAAgB,KAAK,SAAQ,MAAM,eAAwB;iBAetF;;WAEN;;EAET;;EAEA,IAAI,aAAa;;EAEjB,MAAM;;EAEN,MAAM,aAAa;;EAEnB,OAAO;;EAEP,KAAK,GAAG,gBAAgB,MAAM;;EAE9B,SAAS;;EAET,QAAQ,GAAG,gBAAgB,MAAM;;EAEjC,OAAO,GAAG,gBAAgB,KAAK,YAAY;;EAE3C,OAAO,eAAe;;;;;;;EAOtB,OAAO,mBAAmB;;EAE1B,KAAK,gBAAgB;;;wBAQP,OAAO,uBAAuB,UAAS,iBAAiB,SAAsB;;wBAM9E,SAAS,MAAM,QAAQ,cAAc,UAAS,iBAAiB,SAAsB;;;;;;;;;wBAoFrF,UAAU,2BAA2B"}
1
+ {"version":3,"file":"random.d.ts","names":[],"sources":["../src/random.ts"],"mappings":";;;;;;;;YASY;;wBAGI,WAAW,eAAe;;;;;;;;;;;wBAqB1B,QAAQ,cAAc;WAAqB;;;wBA+B3C,OAAO;;wBAOP,WAAW,cAAc;;;;;;;;;;wBAazB,WAAW,GAAG,cAAc,gBAAgB,KAAK,SAAQ,MAAM,eAAwB;iBAetF;;WAEN;;EAET;;EAEA,IAAI,aAAa;;EAEjB,MAAM;;EAEN,MAAM,aAAa;;EAEnB,OAAO;;EAEP,KAAK,GAAG,gBAAgB,MAAM;;EAE9B,SAAS;;EAET,QAAQ,GAAG,gBAAgB,MAAM;;EAEjC,OAAO,GAAG,gBAAgB,KAAK,YAAY;;EAE3C,OAAO,eAAe;;;;;;;EAOtB,OAAO,mBAAmB;;EAE1B,KAAK,gBAAgB;;;wBAQP,OAAO,uBAAuB,UAAS,iBAAiB,SAAsB;;wBAM9E,SAAS,MAAM,QAAQ,cAAc,UAAS,iBAAiB,SAAsB;;;;;;;;;wBAoFrF,UAAU,2BAA2B"}
package/build/random.js CHANGED
@@ -10,15 +10,15 @@ function mulberry32(seed) {
10
10
  return ((t ^ t >>> 14) >>> 0) / 4294967296;
11
11
  };
12
12
  }
13
- const UTF8 = new TextEncoder();
14
13
  /**
15
14
  * The FNV-1a hash of 32 bits of a string. The option `input` selects the units that the hash reads:
16
15
  *
17
- * - `"utf8"` (the default): the UTF-8 bytes from `TextEncoder`. A lone surrogate becomes the bytes of U+FFFD.
16
+ * - `"utf8"` (the default): the UTF-8 bytes, equal to the bytes of `TextEncoder`. A lone surrogate becomes the bytes of U+FFFD.
18
17
  * - `"utf16"`: the UTF-16 code units of the string, one unit for each step, from `charCodeAt`.
19
18
  * - `"wtf8"`: the UTF-8 bytes of each code point. A lone surrogate becomes its own 3 bytes (WTF-8).
20
19
  *
21
- * For a string without a lone surrogate, `"utf8"` and `"wtf8"` give the same hash.
20
+ * For a string without a lone surrogate, `"utf8"` and `"wtf8"` give the same hash. The function uses no API of Node or
21
+ * of the browser, so the hash is the same on each platform.
22
22
  */
23
23
  function fnv1a32(text, options) {
24
24
  const input = options?.input ?? "utf8";
@@ -27,29 +27,26 @@ function fnv1a32(text, options) {
27
27
  for (let i = 0; i < text.length; i++) h = Math.imul(h ^ text.charCodeAt(i), 16777619);
28
28
  return h >>> 0;
29
29
  }
30
- if (input === "wtf8") {
31
- for (const ch of text) {
32
- const c = ch.codePointAt(0);
33
- if (c < 128) h = Math.imul(h ^ c, 16777619);
34
- else if (c < 2048) {
35
- h = Math.imul(h ^ (192 | c >> 6), 16777619);
36
- h = Math.imul(h ^ (128 | c & 63), 16777619);
37
- } else if (c < 65536) {
38
- h = Math.imul(h ^ (224 | c >> 12), 16777619);
39
- h = Math.imul(h ^ (128 | c >> 6 & 63), 16777619);
40
- h = Math.imul(h ^ (128 | c & 63), 16777619);
41
- } else {
42
- h = Math.imul(h ^ (240 | c >> 18), 16777619);
43
- h = Math.imul(h ^ (128 | c >> 12 & 63), 16777619);
44
- h = Math.imul(h ^ (128 | c >> 6 & 63), 16777619);
45
- h = Math.imul(h ^ (128 | c & 63), 16777619);
46
- }
30
+ if (input !== "utf8" && input !== "wtf8") throw new RangeError(`fnv1a32: input is "utf8", "utf16" or "wtf8", not ${String(input)}.`);
31
+ for (const ch of text) {
32
+ let c = ch.codePointAt(0);
33
+ if (input === "utf8" && c >= 55296 && c <= 57343) c = 65533;
34
+ if (c < 128) h = Math.imul(h ^ c, 16777619);
35
+ else if (c < 2048) {
36
+ h = Math.imul(h ^ (192 | c >> 6), 16777619);
37
+ h = Math.imul(h ^ (128 | c & 63), 16777619);
38
+ } else if (c < 65536) {
39
+ h = Math.imul(h ^ (224 | c >> 12), 16777619);
40
+ h = Math.imul(h ^ (128 | c >> 6 & 63), 16777619);
41
+ h = Math.imul(h ^ (128 | c & 63), 16777619);
42
+ } else {
43
+ h = Math.imul(h ^ (240 | c >> 18), 16777619);
44
+ h = Math.imul(h ^ (128 | c >> 12 & 63), 16777619);
45
+ h = Math.imul(h ^ (128 | c >> 6 & 63), 16777619);
46
+ h = Math.imul(h ^ (128 | c & 63), 16777619);
47
47
  }
48
- return h >>> 0;
49
48
  }
50
- if (input !== "utf8") throw new RangeError(`fnv1a32: input is "utf8", "utf16" or "wtf8", not ${String(input)}.`);
51
- for (const b of UTF8.encode(text)) h = Math.imul(h ^ b, 16777619) >>> 0;
52
- return h;
49
+ return h >>> 0;
53
50
  }
54
51
  /** The 32-bit seed of a number (its low 32 bits, unsigned) or of a string (its FNV-1a hash). */
55
52
  function seedOf(seed) {
@@ -1 +1 @@
1
- {"version":3,"file":"random.js","names":[],"sources":["../src/random.ts"],"sourcesContent":["/**\n * A pseudo-random number generator with a seed, and the draws that tests and benchmarks make from it.\n *\n * The generator is mulberry32. It is fast, it has 32 bits of state and it gives the same sequence for\n * the same seed on each platform. It is not for cryptography. Each repository that copied mulberry32\n * gets the same numbers from `random(seed).next`, so a move to this package keeps the records equal.\n */\n\n/** A source of uniform numbers from 0 (included) to 1 (not included). */\nexport type Source = () => number;\n\n/** The generator mulberry32. The seed is read as a 32-bit unsigned integer. */\nexport function mulberry32(seed: number): Source {\n let state = seed >>> 0;\n return () => {\n state = (state + 0x6d2b79f5) >>> 0;\n let t = state;\n t = Math.imul(t ^ (t >>> 15), t | 1);\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\nconst UTF8 = new TextEncoder();\n\n/**\n * The FNV-1a hash of 32 bits of a string. The option `input` selects the units that the hash reads:\n *\n * - `\"utf8\"` (the default): the UTF-8 bytes from `TextEncoder`. A lone surrogate becomes the bytes of U+FFFD.\n * - `\"utf16\"`: the UTF-16 code units of the string, one unit for each step, from `charCodeAt`.\n * - `\"wtf8\"`: the UTF-8 bytes of each code point. A lone surrogate becomes its own 3 bytes (WTF-8).\n *\n * For a string without a lone surrogate, `\"utf8\"` and `\"wtf8\"` give the same hash.\n */\nexport function fnv1a32(text: string, options?: { readonly input?: \"utf8\" | \"utf16\" | \"wtf8\" }): number {\n const input = options?.input ?? \"utf8\";\n let h = 0x811c9dc5;\n if (input === \"utf16\") {\n for (let i = 0; i < text.length; i++) h = Math.imul(h ^ text.charCodeAt(i), 0x01000193);\n return h >>> 0;\n }\n if (input === \"wtf8\") {\n for (const ch of text) {\n const c = ch.codePointAt(0) as number;\n if (c < 0x80) h = Math.imul(h ^ c, 0x01000193);\n else if (c < 0x800) {\n h = Math.imul(h ^ (0xc0 | (c >> 6)), 0x01000193);\n h = Math.imul(h ^ (0x80 | (c & 63)), 0x01000193);\n } else if (c < 0x10000) {\n h = Math.imul(h ^ (0xe0 | (c >> 12)), 0x01000193);\n h = Math.imul(h ^ (0x80 | ((c >> 6) & 63)), 0x01000193);\n h = Math.imul(h ^ (0x80 | (c & 63)), 0x01000193);\n } else {\n h = Math.imul(h ^ (0xf0 | (c >> 18)), 0x01000193);\n h = Math.imul(h ^ (0x80 | ((c >> 12) & 63)), 0x01000193);\n h = Math.imul(h ^ (0x80 | ((c >> 6) & 63)), 0x01000193);\n h = Math.imul(h ^ (0x80 | (c & 63)), 0x01000193);\n }\n }\n return h >>> 0;\n }\n if (input !== \"utf8\") throw new RangeError(`fnv1a32: input is \"utf8\", \"utf16\" or \"wtf8\", not ${String(input)}.`);\n for (const b of UTF8.encode(text)) h = Math.imul(h ^ b, 0x01000193) >>> 0;\n return h;\n}\n\n/** The 32-bit seed of a number (its low 32 bits, unsigned) or of a string (its FNV-1a hash). */\nexport function seedOf(seed: number | string): number {\n if (typeof seed === \"string\") return fnv1a32(seed);\n if (!Number.isFinite(seed)) throw new RangeError(`seedOf: a seed is a finite number or a string, not ${seed}.`);\n return seed >>> 0;\n}\n\n/** The seed of the stream with the name `label` under `seed`: the hash of `\"<seed>:<label>\"`. */\nexport function deriveSeed(seed: number, label: string): number {\n return fnv1a32(`${seed}:${label}`);\n}\n\n/**\n * One item of a list, chosen by highest random weight: each key has a weight from `seed`, and the largest weight wins.\n *\n * - The order of the list does not change the choice. The smaller key wins a tie of weights.\n * - When a list gains an item, only the draws that the new item wins change. For `n` items, the share of those draws is approximately `1 / (n + 1)`.\n * - When a list loses an item, only the draws of that item change.\n *\n * The function reads one hash for each item, so a choice costs O(n). The list is not empty, and each key occurs once.\n */\nexport function stablePick<T>(seed: number, items: readonly T[], keyOf: (item: T) => string = String): T {\n if (items.length === 0) throw new RangeError(\"stablePick: the list is empty.\");\n const start = seedOf(seed);\n const seen = new Set<string>();\n let best: { item: T; key: string; weight: number } | undefined;\n for (const item of items) {\n const key = keyOf(item);\n if (seen.has(key)) throw new RangeError(`stablePick: the key ${JSON.stringify(key)} occurs twice.`);\n seen.add(key);\n const weight = mulberry32(deriveSeed(start, key))();\n if (best === undefined || weight > best.weight || (weight === best.weight && key < best.key)) best = { item, key, weight };\n }\n return (best as { item: T }).item;\n}\n\nexport interface Random {\n /** The 32-bit seed that the generator started with. Write it in each failure message, so a run can replay. */\n readonly seed: number;\n /** A uniform number from 0 (included) to 1 (not included). */\n next(): number;\n /** A uniform integer from `min` to `max`, both included. */\n int(min: number, max: number): number;\n /** A uniform integer from 0 (included) to `n` (not included). */\n below(n: number): number;\n /** A uniform number from `min` (included) to `max` (not included). */\n range(min: number, max: number): number;\n /** `true` with the probability `p`. */\n chance(p: number): boolean;\n /** One item of a list that is not empty, each with the same probability. */\n pick<T>(items: readonly T[]): T;\n /** The index of a weight, with a probability in proportion to the weight. One draw. */\n weighted(weights: readonly number[]): number;\n /** A new list with the items in a uniform random order (Fisher–Yates, from the end). */\n shuffle<T>(items: readonly T[]): T[];\n /** `k` different items of a list, in the order of the draw (a partial Fisher–Yates). */\n sample<T>(items: readonly T[], k: number): T[];\n /** A normal sample (Box–Muller, two draws). */\n normal(mean?: number, sd?: number): number;\n /**\n * A Gumbel sample with the mode `location` and the scale `scale` (the inverse of the CDF, one draw).\n * The mean is `location + 0.5772 * scale`.\n * Add a Gumbel draw with the scale 1 to the log of each weight, and sort by the sums.\n * The order then has the Plackett-Luce law of the weights (the Gumbel-max method).\n */\n gumbel(location?: number, scale?: number): number;\n /** An independent generator for the part of the work with the name `label`. The same labels give the same streams. */\n fork(label: string): Random;\n}\n\nfunction wholeOrThrow(name: string, value: number): void {\n if (!Number.isSafeInteger(value)) throw new RangeError(`${name}: ${value} is not a safe integer.`);\n}\n\n/** A generator with draws, from a seed. The default source is mulberry32. */\nexport function random(seed: number | string, source: (seed: number) => Source = mulberry32): Random {\n const start = seedOf(seed);\n return randomOf(source(start), start, source);\n}\n\n/** A generator with draws, from a source that you give. `fork` uses `source` for the new streams. */\nexport function randomOf(next: Source, seed: number, source: (seed: number) => Source = mulberry32): Random {\n const below = (n: number): number => {\n wholeOrThrow(\"below\", n);\n if (n < 1) throw new RangeError(`below: n is 1 or more, not ${n}.`);\n return Math.floor(next() * n);\n };\n return {\n seed,\n next,\n int(min, max) {\n wholeOrThrow(\"int\", min);\n wholeOrThrow(\"int\", max);\n if (min > max) throw new RangeError(`int: min ${min} is more than max ${max}.`);\n return min + Math.floor(next() * (max - min + 1));\n },\n below,\n range: (min, max) => min + next() * (max - min),\n chance: (p) => next() < p,\n pick(items) {\n if (items.length === 0) throw new RangeError(\"pick: the list is empty.\");\n return items[below(items.length)] as (typeof items)[number];\n },\n weighted(weights) {\n let total = 0;\n for (const w of weights) {\n if (!(Number.isFinite(w) && w >= 0)) throw new RangeError(`weighted: each weight is finite and 0 or more, not ${w}.`);\n total += w;\n }\n if (!(total > 0)) throw new RangeError(\"weighted: the sum of the weights is 0.\");\n let left = next() * total;\n for (let i = 0; i < weights.length; i++) {\n left -= weights[i] as number;\n if (left < 0) return i;\n }\n // Rounding can leave a small remainder: give the last index with a weight.\n for (let i = weights.length - 1; ; i--) if ((weights[i] as number) > 0) return i;\n },\n shuffle(items) {\n const out = [...items];\n for (let i = out.length - 1; i > 0; i--) {\n const j = below(i + 1);\n [out[i], out[j]] = [out[j] as (typeof out)[number], out[i] as (typeof out)[number]];\n }\n return out;\n },\n sample(items, k) {\n wholeOrThrow(\"sample\", k);\n if (k < 0 || k > items.length) throw new RangeError(`sample: k is from 0 to ${items.length}, not ${k}.`);\n const out = [...items];\n for (let i = 0; i < k; i++) {\n const j = i + below(out.length - i);\n [out[i], out[j]] = [out[j] as (typeof out)[number], out[i] as (typeof out)[number]];\n }\n return out.slice(0, k);\n },\n normal(mean = 0, sd = 1) {\n const u1 = Math.max(next(), 1e-12);\n const u2 = next();\n return mean + sd * Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);\n },\n gumbel(location = 0, scale = 1) {\n if (!(Number.isFinite(scale) && scale > 0)) throw new RangeError(`gumbel: the scale is finite and more than 0, not ${scale}.`);\n // The same floor as normal: a draw of 0 gives a finite value, not minus infinity.\n const u = Math.max(next(), 1e-12);\n return location - scale * Math.log(-Math.log(u));\n },\n fork(label) {\n const child = deriveSeed(seed, label);\n return randomOf(source(child), child, source);\n },\n };\n}\n\n/** The largest count of seeds that one range gives. A larger range is an error, not a long run. */\nconst MAX_RANGE = 1_000_000;\n\n/**\n * The seeds of a run: the seeds in `given` (the text of an environment variable, for example\n * `process.env.SEED`), else the default seeds. An empty text gives the defaults.\n *\n * The text is one seed (`17`) or a list of seeds and ranges with commas (`1,3,9-11` gives 1, 3, 9, 10\n * and 11), in the order of the list. A range has two whole numbers, the low one first. An empty part, a\n * part that is not an integer and a range with the low end last are each a `RangeError`.\n */\nexport function seedsFrom(given: string | undefined, defaults: readonly number[]): number[] {\n if (given === undefined || given.trim() === \"\") return [...defaults];\n return given.split(\",\").flatMap((raw) => {\n const part = raw.trim();\n const range = /^(\\d+)\\s*-\\s*(\\d+)$/u.exec(part);\n if (range !== null) {\n const [low, high] = [Number(range[1]), Number(range[2])];\n if (!Number.isSafeInteger(high) || high < low || high - low >= MAX_RANGE) {\n throw new RangeError(`seedsFrom: the range ${part} is not low-high with at most ${MAX_RANGE} seeds.`);\n }\n return Array.from({ length: high - low + 1 }, (_, i) => low + i);\n }\n const seed = part === \"\" ? Number.NaN : Number(part);\n if (!Number.isSafeInteger(seed)) throw new RangeError(`seedsFrom: a seed is an integer, not ${part === \"\" ? \"an empty part\" : part}.`);\n return [seed];\n });\n}\n"],"mappings":";;AAYA,SAAgB,WAAW,MAAsB;CAC/C,IAAI,QAAQ,SAAS;CACrB,aAAa;EACX,QAAS,QAAQ,eAAgB;EACjC,IAAI,IAAI;EACR,IAAI,KAAK,KAAK,IAAK,MAAM,IAAK,IAAI,CAAC;EACnC,KAAK,IAAI,KAAK,KAAK,IAAK,MAAM,GAAI,IAAI,EAAE;EACxC,SAAS,IAAK,MAAM,QAAS,KAAK;CACpC;AACF;AAEA,MAAM,OAAO,IAAI,YAAY;;;;;;;;;;AAW7B,SAAgB,QAAQ,MAAc,SAAkE;CACtG,MAAM,QAAQ,SAAS,SAAS;CAChC,IAAI,IAAI;CACR,IAAI,UAAU,SAAS;EACrB,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,WAAW,CAAC,GAAG,QAAU;EACtF,OAAO,MAAM;CACf;CACA,IAAI,UAAU,QAAQ;EACpB,KAAK,MAAM,MAAM,MAAM;GACrB,MAAM,IAAI,GAAG,YAAY,CAAC;GAC1B,IAAI,IAAI,KAAM,IAAI,KAAK,KAAK,IAAI,GAAG,QAAU;QACxC,IAAI,IAAI,MAAO;IAClB,IAAI,KAAK,KAAK,KAAK,MAAQ,KAAK,IAAK,QAAU;IAC/C,IAAI,KAAK,KAAK,KAAK,MAAQ,IAAI,KAAM,QAAU;GACjD,OAAO,IAAI,IAAI,OAAS;IACtB,IAAI,KAAK,KAAK,KAAK,MAAQ,KAAK,KAAM,QAAU;IAChD,IAAI,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,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,WAAW,oDAAoD,MAAM,EAAE;GAE7H,MAAM,IAAI,KAAK,IAAI,KAAK,GAAG,KAAK;GAChC,OAAO,WAAW,QAAQ,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;EACjD;EACA,KAAK,OAAO;GACV,MAAM,QAAQ,WAAW,MAAM,KAAK;GACpC,OAAO,SAAS,OAAO,KAAK,GAAG,OAAO,MAAM;EAC9C;CACF;AACF;;AAGA,MAAM,YAAY;;;;;;;;;AAUlB,SAAgB,UAAU,OAA2B,UAAuC;CAC1F,IAAI,UAAU,KAAA,KAAa,MAAM,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,QAAQ;CACnE,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,QAAQ;EACvC,MAAM,OAAO,IAAI,KAAK;EACtB,MAAM,QAAQ,uBAAuB,KAAK,IAAI;EAC9C,IAAI,UAAU,MAAM;GAClB,MAAM,CAAC,KAAK,QAAQ,CAAC,OAAO,MAAM,EAAE,GAAG,OAAO,MAAM,EAAE,CAAC;GACvD,IAAI,CAAC,OAAO,cAAc,IAAI,KAAK,OAAO,OAAO,OAAO,OAAO,WAC7D,MAAM,IAAI,WAAW,wBAAwB,KAAK,gCAAgC,UAAU,QAAQ;GAEtG,OAAO,MAAM,KAAK,EAAE,QAAQ,OAAO,MAAM,EAAE,IAAI,GAAG,MAAM,MAAM,CAAC;EACjE;EACA,MAAM,OAAO,SAAS,KAAK,MAAa,OAAO,IAAI;EACnD,IAAI,CAAC,OAAO,cAAc,IAAI,GAAG,MAAM,IAAI,WAAW,wCAAwC,SAAS,KAAK,kBAAkB,KAAK,EAAE;EACrI,OAAO,CAAC,IAAI;CACd,CAAC;AACH"}
1
+ {"version":3,"file":"random.js","names":[],"sources":["../src/random.ts"],"sourcesContent":["/**\n * A pseudo-random number generator with a seed, and the draws that tests and benchmarks make from it.\n *\n * The generator is mulberry32. It is fast, it has 32 bits of state and it gives the same sequence for\n * the same seed on each platform. It is not for cryptography. Each repository that copied mulberry32\n * gets the same numbers from `random(seed).next`, so a move to this package keeps the records equal.\n */\n\n/** A source of uniform numbers from 0 (included) to 1 (not included). */\nexport type Source = () => number;\n\n/** The generator mulberry32. The seed is read as a 32-bit unsigned integer. */\nexport function mulberry32(seed: number): Source {\n let state = seed >>> 0;\n return () => {\n state = (state + 0x6d2b79f5) >>> 0;\n let t = state;\n t = Math.imul(t ^ (t >>> 15), t | 1);\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/**\n * The FNV-1a hash of 32 bits of a string. The option `input` selects the units that the hash reads:\n *\n * - `\"utf8\"` (the default): the UTF-8 bytes, equal to the bytes of `TextEncoder`. A lone surrogate becomes the bytes of U+FFFD.\n * - `\"utf16\"`: the UTF-16 code units of the string, one unit for each step, from `charCodeAt`.\n * - `\"wtf8\"`: the UTF-8 bytes of each code point. A lone surrogate becomes its own 3 bytes (WTF-8).\n *\n * For a string without a lone surrogate, `\"utf8\"` and `\"wtf8\"` give the same hash. The function uses no API of Node or\n * of the browser, so the hash is the same on each platform.\n */\nexport function fnv1a32(text: string, options?: { readonly input?: \"utf8\" | \"utf16\" | \"wtf8\" }): number {\n const input = options?.input ?? \"utf8\";\n let h = 0x811c9dc5;\n if (input === \"utf16\") {\n for (let i = 0; i < text.length; i++) h = Math.imul(h ^ text.charCodeAt(i), 0x01000193);\n return h >>> 0;\n }\n if (input !== \"utf8\" && input !== \"wtf8\") throw new RangeError(`fnv1a32: input is \"utf8\", \"utf16\" or \"wtf8\", not ${String(input)}.`);\n for (const ch of text) {\n let c = ch.codePointAt(0) as number;\n // A string iterator gives a lone surrogate as one code point. UTF-8 writes U+FFFD in its place, as TextEncoder does.\n if (input === \"utf8\" && c >= 0xd800 && c <= 0xdfff) c = 0xfffd;\n if (c < 0x80) h = Math.imul(h ^ c, 0x01000193);\n else if (c < 0x800) {\n h = Math.imul(h ^ (0xc0 | (c >> 6)), 0x01000193);\n h = Math.imul(h ^ (0x80 | (c & 63)), 0x01000193);\n } else if (c < 0x10000) {\n h = Math.imul(h ^ (0xe0 | (c >> 12)), 0x01000193);\n h = Math.imul(h ^ (0x80 | ((c >> 6) & 63)), 0x01000193);\n h = Math.imul(h ^ (0x80 | (c & 63)), 0x01000193);\n } else {\n h = Math.imul(h ^ (0xf0 | (c >> 18)), 0x01000193);\n h = Math.imul(h ^ (0x80 | ((c >> 12) & 63)), 0x01000193);\n h = Math.imul(h ^ (0x80 | ((c >> 6) & 63)), 0x01000193);\n h = Math.imul(h ^ (0x80 | (c & 63)), 0x01000193);\n }\n }\n return h >>> 0;\n}\n\n/** The 32-bit seed of a number (its low 32 bits, unsigned) or of a string (its FNV-1a hash). */\nexport function seedOf(seed: number | string): number {\n if (typeof seed === \"string\") return fnv1a32(seed);\n if (!Number.isFinite(seed)) throw new RangeError(`seedOf: a seed is a finite number or a string, not ${seed}.`);\n return seed >>> 0;\n}\n\n/** The seed of the stream with the name `label` under `seed`: the hash of `\"<seed>:<label>\"`. */\nexport function deriveSeed(seed: number, label: string): number {\n return fnv1a32(`${seed}:${label}`);\n}\n\n/**\n * One item of a list, chosen by highest random weight: each key has a weight from `seed`, and the largest weight wins.\n *\n * - The order of the list does not change the choice. The smaller key wins a tie of weights.\n * - When a list gains an item, only the draws that the new item wins change. For `n` items, the share of those draws is approximately `1 / (n + 1)`.\n * - When a list loses an item, only the draws of that item change.\n *\n * The function reads one hash for each item, so a choice costs O(n). The list is not empty, and each key occurs once.\n */\nexport function stablePick<T>(seed: number, items: readonly T[], keyOf: (item: T) => string = String): T {\n if (items.length === 0) throw new RangeError(\"stablePick: the list is empty.\");\n const start = seedOf(seed);\n const seen = new Set<string>();\n let best: { item: T; key: string; weight: number } | undefined;\n for (const item of items) {\n const key = keyOf(item);\n if (seen.has(key)) throw new RangeError(`stablePick: the key ${JSON.stringify(key)} occurs twice.`);\n seen.add(key);\n const weight = mulberry32(deriveSeed(start, key))();\n if (best === undefined || weight > best.weight || (weight === best.weight && key < best.key)) best = { item, key, weight };\n }\n return (best as { item: T }).item;\n}\n\nexport interface Random {\n /** The 32-bit seed that the generator started with. Write it in each failure message, so a run can replay. */\n readonly seed: number;\n /** A uniform number from 0 (included) to 1 (not included). */\n next(): number;\n /** A uniform integer from `min` to `max`, both included. */\n int(min: number, max: number): number;\n /** A uniform integer from 0 (included) to `n` (not included). */\n below(n: number): number;\n /** A uniform number from `min` (included) to `max` (not included). */\n range(min: number, max: number): number;\n /** `true` with the probability `p`. */\n chance(p: number): boolean;\n /** One item of a list that is not empty, each with the same probability. */\n pick<T>(items: readonly T[]): T;\n /** The index of a weight, with a probability in proportion to the weight. One draw. */\n weighted(weights: readonly number[]): number;\n /** A new list with the items in a uniform random order (Fisher–Yates, from the end). */\n shuffle<T>(items: readonly T[]): T[];\n /** `k` different items of a list, in the order of the draw (a partial Fisher–Yates). */\n sample<T>(items: readonly T[], k: number): T[];\n /** A normal sample (Box–Muller, two draws). */\n normal(mean?: number, sd?: number): number;\n /**\n * A Gumbel sample with the mode `location` and the scale `scale` (the inverse of the CDF, one draw).\n * The mean is `location + 0.5772 * scale`.\n * Add a Gumbel draw with the scale 1 to the log of each weight, and sort by the sums.\n * The order then has the Plackett-Luce law of the weights (the Gumbel-max method).\n */\n gumbel(location?: number, scale?: number): number;\n /** An independent generator for the part of the work with the name `label`. The same labels give the same streams. */\n fork(label: string): Random;\n}\n\nfunction wholeOrThrow(name: string, value: number): void {\n if (!Number.isSafeInteger(value)) throw new RangeError(`${name}: ${value} is not a safe integer.`);\n}\n\n/** A generator with draws, from a seed. The default source is mulberry32. */\nexport function random(seed: number | string, source: (seed: number) => Source = mulberry32): Random {\n const start = seedOf(seed);\n return randomOf(source(start), start, source);\n}\n\n/** A generator with draws, from a source that you give. `fork` uses `source` for the new streams. */\nexport function randomOf(next: Source, seed: number, source: (seed: number) => Source = mulberry32): Random {\n const below = (n: number): number => {\n wholeOrThrow(\"below\", n);\n if (n < 1) throw new RangeError(`below: n is 1 or more, not ${n}.`);\n return Math.floor(next() * n);\n };\n return {\n seed,\n next,\n int(min, max) {\n wholeOrThrow(\"int\", min);\n wholeOrThrow(\"int\", max);\n if (min > max) throw new RangeError(`int: min ${min} is more than max ${max}.`);\n return min + Math.floor(next() * (max - min + 1));\n },\n below,\n range: (min, max) => min + next() * (max - min),\n chance: (p) => next() < p,\n pick(items) {\n if (items.length === 0) throw new RangeError(\"pick: the list is empty.\");\n return items[below(items.length)] as (typeof items)[number];\n },\n weighted(weights) {\n let total = 0;\n for (const w of weights) {\n if (!(Number.isFinite(w) && w >= 0)) throw new RangeError(`weighted: each weight is finite and 0 or more, not ${w}.`);\n total += w;\n }\n if (!(total > 0)) throw new RangeError(\"weighted: the sum of the weights is 0.\");\n let left = next() * total;\n for (let i = 0; i < weights.length; i++) {\n left -= weights[i] as number;\n if (left < 0) return i;\n }\n // Rounding can leave a small remainder: give the last index with a weight.\n for (let i = weights.length - 1; ; i--) if ((weights[i] as number) > 0) return i;\n },\n shuffle(items) {\n const out = [...items];\n for (let i = out.length - 1; i > 0; i--) {\n const j = below(i + 1);\n [out[i], out[j]] = [out[j] as (typeof out)[number], out[i] as (typeof out)[number]];\n }\n return out;\n },\n sample(items, k) {\n wholeOrThrow(\"sample\", k);\n if (k < 0 || k > items.length) throw new RangeError(`sample: k is from 0 to ${items.length}, not ${k}.`);\n const out = [...items];\n for (let i = 0; i < k; i++) {\n const j = i + below(out.length - i);\n [out[i], out[j]] = [out[j] as (typeof out)[number], out[i] as (typeof out)[number]];\n }\n return out.slice(0, k);\n },\n normal(mean = 0, sd = 1) {\n const u1 = Math.max(next(), 1e-12);\n const u2 = next();\n return mean + sd * Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);\n },\n gumbel(location = 0, scale = 1) {\n if (!(Number.isFinite(scale) && scale > 0)) throw new RangeError(`gumbel: the scale is finite and more than 0, not ${scale}.`);\n // The same floor as normal: a draw of 0 gives a finite value, not minus infinity.\n const u = Math.max(next(), 1e-12);\n return location - scale * Math.log(-Math.log(u));\n },\n fork(label) {\n const child = deriveSeed(seed, label);\n return randomOf(source(child), child, source);\n },\n };\n}\n\n/** The largest count of seeds that one range gives. A larger range is an error, not a long run. */\nconst MAX_RANGE = 1_000_000;\n\n/**\n * The seeds of a run: the seeds in `given` (the text of an environment variable, for example\n * `process.env.SEED`), else the default seeds. An empty text gives the defaults.\n *\n * The text is one seed (`17`) or a list of seeds and ranges with commas (`1,3,9-11` gives 1, 3, 9, 10\n * and 11), in the order of the list. A range has two whole numbers, the low one first. An empty part, a\n * part that is not an integer and a range with the low end last are each a `RangeError`.\n */\nexport function seedsFrom(given: string | undefined, defaults: readonly number[]): number[] {\n if (given === undefined || given.trim() === \"\") return [...defaults];\n return given.split(\",\").flatMap((raw) => {\n const part = raw.trim();\n const range = /^(\\d+)\\s*-\\s*(\\d+)$/u.exec(part);\n if (range !== null) {\n const [low, high] = [Number(range[1]), Number(range[2])];\n if (!Number.isSafeInteger(high) || high < low || high - low >= MAX_RANGE) {\n throw new RangeError(`seedsFrom: the range ${part} is not low-high with at most ${MAX_RANGE} seeds.`);\n }\n return Array.from({ length: high - low + 1 }, (_, i) => low + i);\n }\n const seed = part === \"\" ? Number.NaN : Number(part);\n if (!Number.isSafeInteger(seed)) throw new RangeError(`seedsFrom: a seed is an integer, not ${part === \"\" ? \"an empty part\" : part}.`);\n return [seed];\n });\n}\n"],"mappings":";;AAYA,SAAgB,WAAW,MAAsB;CAC/C,IAAI,QAAQ,SAAS;CACrB,aAAa;EACX,QAAS,QAAQ,eAAgB;EACjC,IAAI,IAAI;EACR,IAAI,KAAK,KAAK,IAAK,MAAM,IAAK,IAAI,CAAC;EACnC,KAAK,IAAI,KAAK,KAAK,IAAK,MAAM,GAAI,IAAI,EAAE;EACxC,SAAS,IAAK,MAAM,QAAS,KAAK;CACpC;AACF;;;;;;;;;;;AAYA,SAAgB,QAAQ,MAAc,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C,OAAO,cAAc,IAAI,KAAK,OAAO,OAAO,OAAO,OAAO,WAC7D,MAAM,IAAI,WAAW,wBAAwB,KAAK,gCAAgC,UAAU,QAAQ;GAEtG,OAAO,MAAM,KAAK,EAAE,QAAQ,OAAO,MAAM,EAAE,IAAI,GAAG,MAAM,MAAM,CAAC;EACjE;EACA,MAAM,OAAO,SAAS,KAAK,MAAa,OAAO,IAAI;EACnD,IAAI,CAAC,OAAO,cAAc,IAAI,GAAG,MAAM,IAAI,WAAW,wCAAwC,SAAS,KAAK,kBAAkB,KAAK,EAAE;EACrI,OAAO,CAAC,IAAI;CACd,CAAC;AACH"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/rigor-generators",
4
- "version": "0.1.12",
4
+ "version": "0.1.14",
5
5
  "description": "A seeded random number generator (mulberry32) with the draws that tests and benchmarks make: integers, picks, weights, shuffles, samples, normal values and named streams. It also gives a content hash: SHA-256 and canonical JSON (RFC 8785).",
6
6
  "keywords": [
7
7
  "random",