jeudi 18 mars 2021

How to add random noise to an array of bits in C?

I have an array of ints of predetermined size, all of values of either 1 or 0 hence representing a sequence of bits. I want to randomly 'flip' bits in the array independently of one another with a constant probability (say, 1 in a thousand chance to flip bit i), but I need to do it in a computationally efficient way, as in not by rolling every single bit individually. Is there a good way of doing this in C? I thought of separately randomizing the number of errors and then choosing random indices to flip, but I'm not sure how I would randomize the number of errors to begin with..




Aucun commentaire:

Enregistrer un commentaire