Skip to main content
Deno 2 is finally here 🎉️
Learn more
method ProbabilityObjectArray.prototype.probability
import { ProbabilityObjectArray } from "https://deno.land/x/sptaki@1.2.0/utils/mod.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