getweightedrandomidx - eisclimber/ExPresS-XR GitHub Wiki

RuntimeUtils.GetWeightedRandomIdx(float[])

Method in RuntimeUtils

Summary

Returns a random weighted index provided by an array of probabilities that should add up to 1.0f.

public static int GetWeightedRandomIdx(float[] probabilities)

Parameters

Name Description
float[] probabilities List of probabilities for each index. Should add up to 1.0f.

Type Parameters

Name Description
T

Returns

A random index in the range of _probabilities or -1 if empty.

⚠️ **GitHub.com Fallback** ⚠️