draw-elements-with-probability

- an array A of elements, each with a probability p - a number n

Usage no npm install needed!

<script type="module">
  import drawElementsWithProbability from 'https://cdn.skypack.dev/draw-elements-with-probability';
</script>

README

Input

  • an array A of elements, each with a probability p
  • a number n

Output

An array of n values drawn with replacement from A according to the probabilities p with the additional requirement that no value must occur twice in immediate succession