});

Glimpse of Auto-correction Hamming Code

Miscellaneous coding practice.
The essence of coding is math.

Guidance

For freshman, go through all sections in order.
For program-orientated, skip to source code.
For a quick review, refer to flow chart.

Hint: Content is availabe by click on the last icon in the side-tab of this page.

Process-illustrative

This part will combine source code in background and the input in a more interactive and illustrative way hopefully.

Bits generated and parity computation

A series of bits are generated randomly and their parity are calcuated by single-line code below. Basically Xor (exclusive or) is a operand that mode summation by 2. You may refer to the video for more info.

Initializing parity

It is a trick here to initialize some togglable bit, aka redundancy, to set the parity to ‘0’. This can greatly simplify the detection of error in next step.
Here the redundancy bits are somehow similar to eigenvectors, as shown by there Binary form. They are located in the orange highlighted blocks.
The blocks corresponding blocks are inversed to balance the parity ‘001011’, by toggle ‘001000’, ‘000010’, ‘000001’, in decimal ‘8’, ‘2’, ‘1’. It is shown by codes and plot below.

Error introduce and detect

This is the simplest part, with initialized parity. Any unary noise introduced to the series of bits will lead to change of parity. The new parity is exactly the position of the noise. Shown by code and graph.

Process-lite

Source Code

Flow Chart

Present the holistic process in a graphic approach. Good for a quick review or those who already knows the idea.

Acknowledgement

The blog is inspired by 3Blue1Brown, great thanks to this channel for showing me marvelous math theories.https://www.youtube.com/watch?v=b3NxrZOu_CE

And a note for myself:
Next time, do these stuff at night.