In this and the following coding exercises, we'll look at the three-bit repetition algorithm.
In this exercise, you are given a function called
encode
that creates three copies of a bit noisy_channel
that flips each bit
You have numpy
— imported as np
in the code — to use.
Use np.random.uniform(0, 1)
to see whether or not a bit will get flipped.
This will generate a random number between
Also, the ^
operator in Python might be useful. See here for more details.
To interact with codercises, please switch to a larger screen size.
Learning Objectives: