MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / function

Method function

src/compute-engine/index.ts:1752–1770  ·  view source on GitHub ↗
(
    name: string,
    ops: ReadonlyArray<Expression> | ReadonlyArray<MathJsonExpression>,
    options?: {
      metadata?: Metadata;
      form?: FormOption;
      canonical?: CanonicalOptions;
      structural?: boolean;
      scope?: Scope | undefined;
    }
  )

Source from the content-addressed store, hash-verified

1750 /** @internal Draw the next uniform in [0, 1).
1751 *
1752 * Inside a `WithRandomSeed` frame the draw is the counter-based
1753 * `hash(seed, n)` of the innermost frame, and the frame's counter advances
1754 * (u32, wrapping). Outside any frame the draw is LIVE (`Math.random()`):
1755 * there is no ambient seed to set, so an unframed draw is
1756 * non-deterministic by construction.
1757 */
1758 _random(): number {
1759 const frame = this._runtimeState.randomFrame;
1760 if (frame !== undefined) {
1761 const n = frame.next >>> 0;
1762 frame.next = (frame.next + 1) >>> 0;
1763 return frameDraw(frame.seedLo, frame.seedHi, n);
1764 }
1765 return Math.random();
1766 }
1767
1768 /** @internal A private stream derived from the ambient `WithRandomSeed`
1769 * frame, for the stochastic ESTIMATORS (Monte-Carlo integration, the
1770 * sampled equality probe).
1771 *
1772 * Unlike `_random()`, this consumes NO indices from the frame: an estimator
1773 * that samples 1e7 points must not shift a sibling `Random()` draw, and its

Callers 1

assumeIntegerFunction · 0.95

Calls 2

optionsToInternalFunction · 0.90
boxFunctionFunction · 0.90

Tested by 1

assumeIntegerFunction · 0.76