Skip to main content
The Deno 2 Release Candidate is here
Learn more
method ProbabilityObjectArray.prototype.probability
import { ProbabilityObjectArray } from "https://deno.land/x/sptaki@1.2.0/utils/RandomUtil.d.ts";

Get the relative probability of an element by its key

Example: po = new ProbabilityObjectArray(new ProbabilityObject("a", 5), new ProbabilityObject("b", 1)) po.maxProbability() // returns 5

Parameters

key: K

The key of the element whose relative probability shall be retrieved

Returns

number

The relative probability