npm.nicfv.com
    Preparing search index...

    Function selectRandomWeighted

    • Select a single index in an array at random with different weights.

      Parameters

      • weights: number[]

        The weights for each item

      Returns number

      The 0-based index of the randomly selected item

      const index = SMath.selectRandomWeighted([3.5, 4, 1]); // 1