JSSM, a JavaScript state machine - the FSM for FSL
    Preparing search index...

    Function weighted_histo_key


    • Draws n weighted random samples, extracts a named key from each, and returns a histograph (Map) of how often each key value appeared. Useful for validating that a probabilistic transition distribution is roughly correct over many trials.

      const opts = [
      { to: 'a', probability: 0.7 },
      { to: 'b', probability: 0.3 }
      ];

      weighted_histo_key(1000, opts, 'probability', 'to');
      // Map { 'a' => ~700, 'b' => ~300 }

      Parameters

      • n: number

        Number of samples to draw.

      • opts: any[]

        Non-empty array of weighted objects.

      • prob_prop: string

        Name of the numeric weight property.

      • extract: string

        Name of the property to extract from each sample for histogramming.

      • Optionalrng: JssmRng

        Optional random number generator.

      Returns Map<any, number>

      A Map from extracted key values to their occurrence counts.