mardi 26 octobre 2021

Unbiased Shuffling with Large Number of Duplicates

The Fisher–Yates algorithm generates unbiased random permutations of a finite sequence. The running time is proportional to the number elements being shuffled.

I want to shuffle a few non-zero elements with a large number of zero elements.

Implementing the Fisher–Yates algorithm with a list would lead to the shuffling process taking too long and requiring too much storage. Most steps in the Fisher--Yates algorithm would simply switch the position of duplicate zero elements.

Does there exists a random shuffle (or alternative) algorithm that:

  1. Leads to unbiased permutations
  2. Does not require the shuffling and storing of all duplicate elements



Aucun commentaire:

Enregistrer un commentaire