@the-situation/core 0.5.0-alpha.0 → 0.8.4

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.
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Categorical distribution type for multinoulli prediction markets.
3
+ *
4
+ * Represents a discrete probability distribution over N outcomes
5
+ * where probabilities must be non-negative and sum to approximately 1.
6
+ *
7
+ * ## Invariants
8
+ * - 1 <= n <= 81
9
+ * - All probabilities >= 0
10
+ * - Sum of probabilities ≈ 1 (within tolerance 1e-9)
11
+ *
12
+ * @module
13
+ */
14
+ import type { SQ128x128Raw } from '../math/sq128-raw';
15
+ /**
16
+ * Raw categorical distribution from contract.
17
+ * Array of SQ128x128 probability values.
18
+ */
19
+ export interface CategoricalDistributionRaw {
20
+ readonly probs: readonly SQ128x128Raw[];
21
+ }
22
+ /**
23
+ * Raw L2 norm hint for categorical distributions.
24
+ */
25
+ export interface CategoricalL2HintRaw {
26
+ readonly l2NormHint: SQ128x128Raw;
27
+ }
28
+ /**
29
+ * CategoricalDistribution represents a discrete probability distribution
30
+ * over N outcomes for multinoulli prediction markets.
31
+ *
32
+ * Probabilities must be non-negative and sum to approximately 1 (within tolerance ~2^-40).
33
+ *
34
+ * Immutable: all fields are readonly.
35
+ */
36
+ export declare class CategoricalDistribution {
37
+ /** Number of outcomes */
38
+ readonly n: number;
39
+ /** Probability values (readonly) */
40
+ readonly probs: readonly number[];
41
+ private constructor();
42
+ /**
43
+ * Creates a CategoricalDistribution from a probability vector.
44
+ *
45
+ * @param probs - The probability vector (must sum to ~1, all non-negative, length in [1, 81])
46
+ * @returns The distribution, or null if validation fails
47
+ */
48
+ static create(probs: readonly number[]): CategoricalDistribution | null;
49
+ /**
50
+ * Creates a uniform distribution over n outcomes.
51
+ *
52
+ * @param n - The number of outcomes (must be in [1, 81])
53
+ * @returns The uniform distribution, or null if n is invalid
54
+ */
55
+ static uniform(n: number): CategoricalDistribution | null;
56
+ /**
57
+ * Gets probability for outcome i.
58
+ *
59
+ * @param i - The outcome index
60
+ * @returns The probability, or 0 if index is out of bounds
61
+ */
62
+ prob(i: number): number;
63
+ /**
64
+ * Computes L2 norm: sqrt(sum(pi^2)).
65
+ *
66
+ * @returns The L2 norm of the probability vector
67
+ */
68
+ l2Norm(): number;
69
+ /**
70
+ * Returns true if all probabilities are equal.
71
+ */
72
+ isUniform(): boolean;
73
+ /**
74
+ * Returns true if this is a degenerate (point mass) distribution.
75
+ *
76
+ * A degenerate categorical distribution has one probability ~1
77
+ * and the rest ~0, representing a certain outcome.
78
+ */
79
+ isDegenerate(): boolean;
80
+ /**
81
+ * Returns true if distributions have same probabilities.
82
+ *
83
+ * @param other - The other distribution to compare
84
+ * @returns True if the distributions are identical
85
+ */
86
+ isIdentical(other: CategoricalDistribution): boolean;
87
+ /**
88
+ * Maximum probability value.
89
+ *
90
+ * @returns The largest probability in the distribution
91
+ */
92
+ maxProb(): number;
93
+ /**
94
+ * Index of maximum probability.
95
+ *
96
+ * @returns The index of the outcome with the highest probability
97
+ */
98
+ maxProbIndex(): number;
99
+ /**
100
+ * Converts to raw contract format.
101
+ *
102
+ * @param encode - A function to encode a number as SQ128x128Raw
103
+ * @returns The raw representation, or null if encoding fails
104
+ */
105
+ toRaw(encode: (n: number) => SQ128x128Raw | null): CategoricalDistributionRaw | null;
106
+ /**
107
+ * Creates from raw contract format.
108
+ *
109
+ * @param raw - The raw representation from contract
110
+ * @param decode - A function to decode SQ128x128Raw to a number
111
+ * @returns The distribution, or null if decoding or validation fails
112
+ */
113
+ static fromRaw(raw: CategoricalDistributionRaw, decode: (r: SQ128x128Raw) => number | null): CategoricalDistribution | null;
114
+ }
115
+ //# sourceMappingURL=categorical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categorical.d.ts","sourceRoot":"","sources":["../../src/distributions/categorical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mB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li prediction markets.
3
+ *
4
+ * Represents a discrete probability distribution over N outcomes
5
+ * where probabilities must be non-negative and sum to approximately 1.
6
+ *
7
+ * ## Invariants
8
+ * - 1 <= n <= 81
9
+ * - All probabilities >= 0
10
+ * - Sum of probabilities ≈ 1 (within tolerance 1e-9)
11
+ *
12
+ * @module
13
+ */
14
+ /**
15
+ * CategoricalDistribution represents a discrete probability distribution
16
+ * over N outcomes for multinoulli prediction markets.
17
+ *
18
+ * Probabilities must be non-negative and sum to approximately 1 (within tolerance ~2^-40).
19
+ *
20
+ * Immutable: all fields are readonly.
21
+ */
22
+ export class CategoricalDistribution {
23
+ /** Number of outcomes */
24
+ n;
25
+ /** Probability values (readonly) */
26
+ probs;
27
+ constructor(probs) {
28
+ this.probs = probs;
29
+ this.n = probs.length;
30
+ }
31
+ /**
32
+ * Creates a CategoricalDistribution from a probability vector.
33
+ *
34
+ * @param probs - The probability vector (must sum to ~1, all non-negative, length in [1, 81])
35
+ * @returns The distribution, or null if validation fails
36
+ */
37
+ static create(probs) {
38
+ if (probs.length < 1 || probs.length > 81)
39
+ return null;
40
+ let sum = 0;
41
+ for (const p of probs) {
42
+ if (p < 0 || !Number.isFinite(p))
43
+ return null;
44
+ sum += p;
45
+ }
46
+ // Tolerance: ~2^-40 ≈ 9.1e-13, but use 1e-9 for floating point
47
+ if (Math.abs(sum - 1) > 1e-9)
48
+ return null;
49
+ return new CategoricalDistribution(probs);
50
+ }
51
+ /**
52
+ * Creates a uniform distribution over n outcomes.
53
+ *
54
+ * @param n - The number of outcomes (must be in [1, 81])
55
+ * @returns The uniform distribution, or null if n is invalid
56
+ */
57
+ static uniform(n) {
58
+ if (n < 1 || n > 81)
59
+ return null;
60
+ const p = 1 / n;
61
+ return new CategoricalDistribution(Array(n).fill(p));
62
+ }
63
+ /**
64
+ * Gets probability for outcome i.
65
+ *
66
+ * @param i - The outcome index
67
+ * @returns The probability, or 0 if index is out of bounds
68
+ */
69
+ prob(i) {
70
+ if (i < 0 || i >= this.n)
71
+ return 0;
72
+ return this.probs[i];
73
+ }
74
+ /**
75
+ * Computes L2 norm: sqrt(sum(pi^2)).
76
+ *
77
+ * @returns The L2 norm of the probability vector
78
+ */
79
+ l2Norm() {
80
+ let sumSq = 0;
81
+ for (const p of this.probs) {
82
+ sumSq += p * p;
83
+ }
84
+ return Math.sqrt(sumSq);
85
+ }
86
+ /**
87
+ * Returns true if all probabilities are equal.
88
+ */
89
+ isUniform() {
90
+ if (this.n === 0)
91
+ return true;
92
+ const expected = 1 / this.n;
93
+ for (const p of this.probs) {
94
+ if (Math.abs(p - expected) > 1e-12)
95
+ return false;
96
+ }
97
+ return true;
98
+ }
99
+ /**
100
+ * Returns true if this is a degenerate (point mass) distribution.
101
+ *
102
+ * A degenerate categorical distribution has one probability ~1
103
+ * and the rest ~0, representing a certain outcome.
104
+ */
105
+ isDegenerate() {
106
+ let countNearOne = 0;
107
+ for (const p of this.probs) {
108
+ if (Math.abs(p - 1) < 1e-12)
109
+ countNearOne++;
110
+ }
111
+ return countNearOne === 1;
112
+ }
113
+ /**
114
+ * Returns true if distributions have same probabilities.
115
+ *
116
+ * @param other - The other distribution to compare
117
+ * @returns True if the distributions are identical
118
+ */
119
+ isIdentical(other) {
120
+ if (this.n !== other.n)
121
+ return false;
122
+ for (let i = 0; i < this.n; i++) {
123
+ if (Math.abs(this.probs[i] - other.probs[i]) > 1e-12)
124
+ return false;
125
+ }
126
+ return true;
127
+ }
128
+ /**
129
+ * Maximum probability value.
130
+ *
131
+ * @returns The largest probability in the distribution
132
+ */
133
+ maxProb() {
134
+ let max = 0;
135
+ for (const p of this.probs) {
136
+ if (p > max)
137
+ max = p;
138
+ }
139
+ return max;
140
+ }
141
+ /**
142
+ * Index of maximum probability.
143
+ *
144
+ * @returns The index of the outcome with the highest probability
145
+ */
146
+ maxProbIndex() {
147
+ let maxIdx = 0;
148
+ let maxVal = 0;
149
+ for (let i = 0; i < this.n; i++) {
150
+ if (this.probs[i] > maxVal) {
151
+ maxVal = this.probs[i];
152
+ maxIdx = i;
153
+ }
154
+ }
155
+ return maxIdx;
156
+ }
157
+ /**
158
+ * Converts to raw contract format.
159
+ *
160
+ * @param encode - A function to encode a number as SQ128x128Raw
161
+ * @returns The raw representation, or null if encoding fails
162
+ */
163
+ toRaw(encode) {
164
+ const rawProbs = [];
165
+ for (const p of this.probs) {
166
+ const raw = encode(p);
167
+ if (!raw)
168
+ return null;
169
+ rawProbs.push(raw);
170
+ }
171
+ return { probs: rawProbs };
172
+ }
173
+ /**
174
+ * Creates from raw contract format.
175
+ *
176
+ * @param raw - The raw representation from contract
177
+ * @param decode - A function to decode SQ128x128Raw to a number
178
+ * @returns The distribution, or null if decoding or validation fails
179
+ */
180
+ static fromRaw(raw, decode) {
181
+ const probs = [];
182
+ for (const rawP of raw.probs) {
183
+ const p = decode(rawP);
184
+ if (p === null)
185
+ return null;
186
+ probs.push(p);
187
+ }
188
+ return CategoricalDistribution.create(probs);
189
+ }
190
+ }
191
+ //# sourceMappingURL=categorical.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categorical.js","sourceRoot":"","sources":["../../src/distributions/categorical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAmBH;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAuB;IAClC,yBAAyB;IACT,CAAC,CAAS;IAC1B,oCAAoC;IACpB,KAAK,CAAoB;IAEzC,YAAoB,KAAwB;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAwB;QACpC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE;YAAE,OAAO,IAAI,CAAC;QAEvD,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,IA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,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAE,GAAG,MAAM,EAAE,CAAC;gBAC5B,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC;gBACxB,MAAM,GAAG,CAAC,CAAC;YACb,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAA0C;QAC9C,MAAM,QAAQ,GAAmB,EAAE,CAAC;QACpC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,CAAC,GAAG;gBAAE,OAAO,IAAI,CAAC;YACtB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CACZ,GAA+B,EAC/B,MAA0C;QAE1C,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YAC7B,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO,IAAI,CAAC;YAC5B,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;QACD,OAAO,uBAAuB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Distribution types and market type discriminator.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Discriminated union for market types.
8
+ *
9
+ * - `'normal'` — continuous Gaussian markets (NormalDistribution)
10
+ * - `'multinoulli'` — discrete categorical markets (CategoricalDistribution)
11
+ */
12
+ export type MarketType = 'normal' | 'multinoulli';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/distributions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,aAAa,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Distribution types and market type discriminator.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/distributions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -82,9 +82,24 @@ export declare class UnsupportedError extends UnsupportedError_base<{
82
82
  readonly message: string;
83
83
  }> {
84
84
  }
85
+ declare const MarketTypeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
86
+ readonly _tag: "MarketTypeError";
87
+ } & Readonly<A>;
88
+ /**
89
+ * Operation was attempted on a market with an incompatible type.
90
+ *
91
+ * For example, attempting normal distribution operations on a multinoulli market
92
+ * or vice versa.
93
+ */
94
+ export declare class MarketTypeError extends MarketTypeError_base<{
95
+ readonly message: string;
96
+ readonly expected?: string;
97
+ readonly actual?: string;
98
+ }> {
99
+ }
85
100
  /**
86
101
  * Union type covering all SDK errors for catch-all handling.
87
102
  */
88
- export type SdkError = InvalidInputError | SolverFailedError | RpcError | MissingDataError | ExecutionError | NotConnectedError | UnsupportedError;
103
+ export type SdkError = InvalidInputError | SolverFailedError | RpcError | MissingDataError | ExecutionError | NotConnectedError | UnsupportedError | MarketTypeError;
89
104
  export {};
90
105
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","s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M,CAAC;CAC1B,CAAC;CAAG;;;;AAEL;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,qBAAoC;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;CAAG;AAEL;;GAEG;AACH,MAAM,MAAM,QAAQ,GAChB,iBAAiB,GACjB,iBAAiB,GACjB,QAAQ,GACR,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,eAAe,CAAC"}
@@ -42,4 +42,12 @@ export class NotConnectedError extends Data.TaggedError('NotConnectedError') {
42
42
  */
43
43
  export class UnsupportedError extends Data.TaggedError('UnsupportedError') {
44
44
  }
45
+ /**
46
+ * Operation was attempted on a market with an incompatible type.
47
+ *
48
+ * For example, attempting normal distribution operations on a multinoulli market
49
+ * or vice versa.
50
+ */
51
+ export class MarketTypeError extends Data.TaggedError('MarketTypeError') {
52
+ }
45
53
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAGzE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAGzE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,IAAI,CAAC,WAAW,CAAC,UAAU,CAGvD;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAGvE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAInE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAEzE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAEvE;CAAG"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAGzE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAGzE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,IAAI,CAAC,WAAW,CAAC,UAAU,CAGvD;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAGvE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAInE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAEzE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAEvE;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAIrE;CAAG"}
package/dist/index.d.ts CHANGED
@@ -10,5 +10,7 @@ export { EXP_NEG_TABLE, HALF, INV_SQRT_2PI, MAX, MIN, NEG_ONE, ONE, SQ128x128, T
10
10
  export type { Distribution } from './distributions/distribution';
11
11
  export { NormalDistribution, type NormalDistributionRaw } from './distributions/normal-distribution';
12
12
  export type { NormalSqrtHintsRaw } from './distributions/normal-sqrt-hints-raw';
13
- export { ExecutionError, InvalidInputError, MissingDataError, NotConnectedError, RpcError, type SdkError, SolverFailedError, UnsupportedError, } from './errors';
13
+ export { CategoricalDistribution, type CategoricalDistributionRaw, type CategoricalL2HintRaw, } from './distributions/categorical';
14
+ export type { MarketType } from './distributions';
15
+ export { ExecutionError, InvalidInputError, MarketTypeError, MissingDataError, NotConnectedError, RpcError, type SdkError, SolverFailedError, UnsupportedError, } from './errors';
14
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,OAAO,EACP,KAAK,YAAY,EACjB,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,GAAG,EACH,GAAG,EACH,OAAO,EACP,GAAG,EACH,SAAS,EACT,GAAG,EACH,IAAI,GACL,MAAM,cAAc,CAAC;AAGtB,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACrG,YAAY,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAGhF,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,KAAK,QAAQ,EACb,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,OAAO,EACP,KAAK,YAAY,EACjB,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,GAAG,EACH,GAAG,EACH,OAAO,EACP,GAAG,EACH,SAAS,EACT,GAAG,EACH,IAAI,GACL,MAAM,cAAc,CAAC;AAGtB,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACrG,YAAY,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAGhF,OAAO,EACL,uBAAuB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,GAC1B,MAAM,6BAA6B,CAAC;AAGrC,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,KAAK,QAAQ,EACb,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -10,6 +10,8 @@ export { createSQ128x128Raw, isValidSQ128x128Raw, MAX_LIMB, NEG_ONE_RAW, ONE_RAW
10
10
  export { EXP_NEG_TABLE, HALF, INV_SQRT_2PI, MAX, MIN, NEG_ONE, ONE, SQ128x128, TWO, ZERO, } from './math/sq128';
11
11
  // Normal distribution
12
12
  export { NormalDistribution } from './distributions/normal-distribution';
13
+ // Categorical distribution
14
+ export { CategoricalDistribution, } from './distributions/categorical';
13
15
  // Effect error hierarchy
14
- export { ExecutionError, InvalidInputError, MissingDataError, NotConnectedError, RpcError, SolverFailedError, UnsupportedError, } from './errors';
16
+ export { ExecutionError, InvalidInputError, MarketTypeError, MissingDataError, NotConnectedError, RpcError, SolverFailedError, UnsupportedError, } from './errors';
15
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kBAAkB;AAClB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,OAAO,EAEP,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,GAAG,EACH,GAAG,EACH,OAAO,EACP,GAAG,EACH,SAAS,EACT,GAAG,EACH,IAAI,GACL,MAAM,cAAc,CAAC;AAKtB,sBAAsB;AACtB,OAAO,EAAE,kBAAkB,EAA8B,MAAM,qCAAqC,CAAC;AAGrG,yBAAyB;AACzB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EAER,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kBAAkB;AAClB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,OAAO,EAEP,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,GAAG,EACH,GAAG,EACH,OAAO,EACP,GAAG,EACH,SAAS,EACT,GAAG,EACH,IAAI,GACL,MAAM,cAAc,CAAC;AAKtB,sBAAsB;AACtB,OAAO,EAAE,kBAAkB,EAA8B,MAAM,qCAAqC,CAAC;AAGrG,2BAA2B;AAC3B,OAAO,EACL,uBAAuB,GAGxB,MAAM,6BAA6B,CAAC;AAKrC,yBAAyB;AACzB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EAER,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-situation/core",
3
- "version": "0.5.0-alpha.0",
3
+ "version": "0.8.4",
4
4
  "description": "Core types, math primitives, and Effect error hierarchy for The Situation SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,7 +11,9 @@
11
11
  "types": "./dist/index.d.ts"
12
12
  }
13
13
  },
14
- "files": ["dist"],
14
+ "files": [
15
+ "dist"
16
+ ],
15
17
  "scripts": {
16
18
  "build": "tsc -b",
17
19
  "typecheck": "tsc -b",