@almadar/std 2.0.0 → 2.1.0

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,4 +1,4 @@
1
- import { a as StdOperatorMeta } from '../types-I95R8_FN.js';
1
+ import { a as StdOperatorMeta } from '../types-CmNM_IbV.js';
2
2
 
3
3
  /**
4
4
  * Array Module - Collection Operations
@@ -1,4 +1,4 @@
1
- import { a as StdOperatorMeta } from '../types-I95R8_FN.js';
1
+ import { a as StdOperatorMeta } from '../types-CmNM_IbV.js';
2
2
 
3
3
  /**
4
4
  * Async Module - Asynchronous Operations
@@ -1,4 +1,4 @@
1
- import { a as StdOperatorMeta } from '../types-I95R8_FN.js';
1
+ import { a as StdOperatorMeta } from '../types-CmNM_IbV.js';
2
2
 
3
3
  /**
4
4
  * Format Module - Display Formatting
@@ -9,4 +9,5 @@ export { ASYNC_OPERATORS, getAsyncOperators } from './async.js';
9
9
  export { NN_OPERATORS, getNnOperators } from './nn.js';
10
10
  export { TENSOR_OPERATORS, getTensorOperators } from './tensor.js';
11
11
  export { TRAIN_OPERATORS, getTrainOperators } from './train.js';
12
- import '../types-I95R8_FN.js';
12
+ export { PROB_OPERATORS, getProbOperators } from './prob.js';
13
+ import '../types-CmNM_IbV.js';
@@ -3154,6 +3154,232 @@ function getTrainOperators() {
3154
3154
  return Object.keys(TRAIN_OPERATORS);
3155
3155
  }
3156
3156
 
3157
- export { ARRAY_OPERATORS, ASYNC_OPERATORS, FORMAT_OPERATORS, MATH_OPERATORS, NN_OPERATORS, OBJECT_OPERATORS, STR_OPERATORS, TENSOR_OPERATORS, TIME_OPERATORS, TRAIN_OPERATORS, VALIDATE_OPERATORS, getArrayOperators, getAsyncOperators, getFormatOperators, getLambdaArrayOperators, getMathOperators, getNnOperators, getObjectOperators, getStrOperators, getTensorOperators, getTimeOperators, getTrainOperators, getValidateOperators };
3157
+ // modules/prob.ts
3158
+ var PROB_OPERATORS = {
3159
+ // ========================================
3160
+ // Distribution Sampling
3161
+ // ========================================
3162
+ "prob/seed": {
3163
+ module: "prob",
3164
+ category: "std-prob",
3165
+ minArity: 1,
3166
+ maxArity: 1,
3167
+ description: "Set seeded PRNG for deterministic probabilistic sampling",
3168
+ hasSideEffects: true,
3169
+ returnType: "void",
3170
+ params: [{ name: "n", type: "number", description: "Seed value (integer)" }],
3171
+ example: '["prob/seed", 42]'
3172
+ },
3173
+ "prob/flip": {
3174
+ module: "prob",
3175
+ category: "std-prob",
3176
+ minArity: 1,
3177
+ maxArity: 1,
3178
+ description: "Bernoulli trial: returns true with probability p",
3179
+ hasSideEffects: false,
3180
+ returnType: "boolean",
3181
+ params: [{ name: "p", type: "number", description: "Probability of true (0 to 1)" }],
3182
+ example: '["prob/flip", 0.5] // => true or false with equal probability'
3183
+ },
3184
+ "prob/gaussian": {
3185
+ module: "prob",
3186
+ category: "std-prob",
3187
+ minArity: 2,
3188
+ maxArity: 2,
3189
+ description: "Sample from a Gaussian (normal) distribution",
3190
+ hasSideEffects: false,
3191
+ returnType: "number",
3192
+ params: [
3193
+ { name: "mu", type: "number", description: "Mean" },
3194
+ { name: "sigma", type: "number", description: "Standard deviation" }
3195
+ ],
3196
+ example: '["prob/gaussian", 0, 1] // => standard normal sample'
3197
+ },
3198
+ "prob/uniform": {
3199
+ module: "prob",
3200
+ category: "std-prob",
3201
+ minArity: 2,
3202
+ maxArity: 2,
3203
+ description: "Sample from a uniform distribution [lo, hi)",
3204
+ hasSideEffects: false,
3205
+ returnType: "number",
3206
+ params: [
3207
+ { name: "lo", type: "number", description: "Lower bound (inclusive)" },
3208
+ { name: "hi", type: "number", description: "Upper bound (exclusive)" }
3209
+ ],
3210
+ example: '["prob/uniform", 0, 10] // => number in [0, 10)'
3211
+ },
3212
+ "prob/beta": {
3213
+ module: "prob",
3214
+ category: "std-prob",
3215
+ minArity: 2,
3216
+ maxArity: 2,
3217
+ description: "Sample from a Beta(alpha, beta) distribution",
3218
+ hasSideEffects: false,
3219
+ returnType: "number",
3220
+ params: [
3221
+ { name: "alpha", type: "number", description: "Alpha shape parameter (> 0)" },
3222
+ { name: "beta", type: "number", description: "Beta shape parameter (> 0)" }
3223
+ ],
3224
+ example: '["prob/beta", 2, 5] // => number in [0, 1], mean ~ 0.286'
3225
+ },
3226
+ "prob/categorical": {
3227
+ module: "prob",
3228
+ category: "std-prob",
3229
+ minArity: 2,
3230
+ maxArity: 2,
3231
+ description: "Weighted random selection from items",
3232
+ hasSideEffects: false,
3233
+ returnType: "any",
3234
+ params: [
3235
+ { name: "items", type: "array", description: "Array of items to choose from" },
3236
+ { name: "weights", type: "number[]", description: "Array of weights (same length as items)" }
3237
+ ],
3238
+ example: '["prob/categorical", ["a", "b", "c"], [1, 2, 1]] // => "b" most likely'
3239
+ },
3240
+ "prob/poisson": {
3241
+ module: "prob",
3242
+ category: "std-prob",
3243
+ minArity: 1,
3244
+ maxArity: 1,
3245
+ description: "Sample from a Poisson distribution",
3246
+ hasSideEffects: false,
3247
+ returnType: "number",
3248
+ params: [{ name: "lambda", type: "number", description: "Rate parameter (> 0)" }],
3249
+ example: '["prob/poisson", 4] // => non-negative integer, mean ~ 4'
3250
+ },
3251
+ // ========================================
3252
+ // Inference
3253
+ // ========================================
3254
+ "prob/condition": {
3255
+ module: "prob",
3256
+ category: "std-prob",
3257
+ minArity: 1,
3258
+ maxArity: 1,
3259
+ description: "Mark current sample as rejected if predicate is false",
3260
+ hasSideEffects: true,
3261
+ returnType: "void",
3262
+ params: [{ name: "predicate", type: "boolean", description: "Condition that must hold" }],
3263
+ example: '["prob/condition", [">", "@entity.x", 0]]'
3264
+ },
3265
+ "prob/sample": {
3266
+ module: "prob",
3267
+ category: "std-prob",
3268
+ minArity: 2,
3269
+ maxArity: 2,
3270
+ description: "Evaluate an expression n times and collect results",
3271
+ hasSideEffects: false,
3272
+ returnType: "array",
3273
+ params: [
3274
+ { name: "n", type: "number", description: "Number of samples" },
3275
+ { name: "expr", type: "SExpr", description: "Expression to evaluate (lazy)" }
3276
+ ],
3277
+ example: '["prob/sample", 1000, ["prob/flip", 0.5]] // => array of booleans'
3278
+ },
3279
+ "prob/posterior": {
3280
+ module: "prob",
3281
+ category: "std-prob",
3282
+ minArity: 4,
3283
+ maxArity: 4,
3284
+ description: "Rejection sampling: returns accepted query values",
3285
+ hasSideEffects: false,
3286
+ returnType: "array",
3287
+ params: [
3288
+ { name: "model", type: "SExpr", description: "Model expression (lazy, may call set/condition)" },
3289
+ { name: "evidence", type: "SExpr", description: "Evidence expression (lazy, boolean)" },
3290
+ { name: "query", type: "SExpr", description: "Query expression (lazy, value to collect)" },
3291
+ { name: "n", type: "number", description: "Number of samples to attempt" }
3292
+ ],
3293
+ example: '["prob/posterior", model, evidence, query, 5000]'
3294
+ },
3295
+ "prob/infer": {
3296
+ module: "prob",
3297
+ category: "std-prob",
3298
+ minArity: 4,
3299
+ maxArity: 4,
3300
+ description: "Like posterior but returns {mean, variance, samples, acceptRate}",
3301
+ hasSideEffects: false,
3302
+ returnType: "object",
3303
+ params: [
3304
+ { name: "model", type: "SExpr", description: "Model expression (lazy)" },
3305
+ { name: "evidence", type: "SExpr", description: "Evidence expression (lazy, boolean)" },
3306
+ { name: "query", type: "SExpr", description: "Query expression (lazy)" },
3307
+ { name: "n", type: "number", description: "Number of samples to attempt" }
3308
+ ],
3309
+ example: '["prob/infer", model, evidence, query, 5000]'
3310
+ },
3311
+ // ========================================
3312
+ // Statistics
3313
+ // ========================================
3314
+ "prob/expected-value": {
3315
+ module: "prob",
3316
+ category: "std-prob",
3317
+ minArity: 1,
3318
+ maxArity: 1,
3319
+ description: "Mean of numeric samples",
3320
+ hasSideEffects: false,
3321
+ returnType: "number",
3322
+ params: [{ name: "samples", type: "number[]", description: "Array of numeric samples" }],
3323
+ example: '["prob/expected-value", [2, 4, 6, 8]] // => 5'
3324
+ },
3325
+ "prob/variance": {
3326
+ module: "prob",
3327
+ category: "std-prob",
3328
+ minArity: 1,
3329
+ maxArity: 1,
3330
+ description: "Population variance of numeric samples",
3331
+ hasSideEffects: false,
3332
+ returnType: "number",
3333
+ params: [{ name: "samples", type: "number[]", description: "Array of numeric samples" }],
3334
+ example: '["prob/variance", [2, 4, 4, 4, 5, 5, 7, 9]] // => 4'
3335
+ },
3336
+ "prob/histogram": {
3337
+ module: "prob",
3338
+ category: "std-prob",
3339
+ minArity: 2,
3340
+ maxArity: 2,
3341
+ description: "Bin numeric samples into a histogram",
3342
+ hasSideEffects: false,
3343
+ returnType: "object",
3344
+ params: [
3345
+ { name: "samples", type: "number[]", description: "Array of numeric samples" },
3346
+ { name: "bins", type: "number", description: "Number of bins" }
3347
+ ],
3348
+ example: '["prob/histogram", [1, 2, 3, 4, 5], 2] // => {binEdges, counts}'
3349
+ },
3350
+ "prob/percentile": {
3351
+ module: "prob",
3352
+ category: "std-prob",
3353
+ minArity: 2,
3354
+ maxArity: 2,
3355
+ description: "Get the p-th percentile (0-100) from samples",
3356
+ hasSideEffects: false,
3357
+ returnType: "number",
3358
+ params: [
3359
+ { name: "samples", type: "number[]", description: "Array of numeric samples" },
3360
+ { name: "p", type: "number", description: "Percentile (0 to 100)" }
3361
+ ],
3362
+ example: '["prob/percentile", [1, 2, 3, 4, 5], 50] // => 3'
3363
+ },
3364
+ "prob/credible-interval": {
3365
+ module: "prob",
3366
+ category: "std-prob",
3367
+ minArity: 2,
3368
+ maxArity: 2,
3369
+ description: "Compute symmetric credible interval from samples",
3370
+ hasSideEffects: false,
3371
+ returnType: "array",
3372
+ params: [
3373
+ { name: "samples", type: "number[]", description: "Array of numeric samples" },
3374
+ { name: "alpha", type: "number", description: "Significance level (e.g., 0.05 for 95% interval)" }
3375
+ ],
3376
+ example: '["prob/credible-interval", samples, 0.05] // => [lo, hi]'
3377
+ }
3378
+ };
3379
+ function getProbOperators() {
3380
+ return PROB_OPERATORS;
3381
+ }
3382
+
3383
+ export { ARRAY_OPERATORS, ASYNC_OPERATORS, FORMAT_OPERATORS, MATH_OPERATORS, NN_OPERATORS, OBJECT_OPERATORS, PROB_OPERATORS, STR_OPERATORS, TENSOR_OPERATORS, TIME_OPERATORS, TRAIN_OPERATORS, VALIDATE_OPERATORS, getArrayOperators, getAsyncOperators, getFormatOperators, getLambdaArrayOperators, getMathOperators, getNnOperators, getObjectOperators, getProbOperators, getStrOperators, getTensorOperators, getTimeOperators, getTrainOperators, getValidateOperators };
3158
3384
  //# sourceMappingURL=index.js.map
3159
3385
  //# sourceMappingURL=index.js.map