
Introduction to Reed-Solomon and Berlekamp-Welch - jtolds
https://innovation.vivint.com/introduction-to-reed-solomon-bc264d0794f8
======
kdkeyser
Fun to read, well written, but I am not a big fan of the "oversampling" based
explanation, as you start to think about functions on real values that way,
while it is really finite field maths that underpins the working of these
codes.

Also, Reed Solomon is not a particularly great forward error correcting code.
They are optimal as "erasure codes" (i.e, you can lose some data, but the
remaining data cannot have changed), but as error correcting codes, LDPC codes
/ Turbo codes outperform them a lot: e.g. satellite communication (DVB-S2),
hard drive error correction all switched to LDPC's.

~~~
planteen
I thought Reed-Solomon also worked with a mix of erasures and errors? I wasn't
aware of a requirement that erasures can't be corrected in the presence of
errors unless you have hit the erasure limit for your chosen code.

~~~
kdkeyser
For an n+k Reed Solomon code, you can recover from k erasures, but only from
k/2 errors.

~~~
planteen
Right, so could you recover from k/2 erasures with k/4 errors?

~~~
nullc
you can unambiguously recover from floor((k-e)/2) errors in the presence of e
erasures.

------
brian-armstrong
Nice. There are quite a few implementations of R-S floating around out there

I'll plug mine, too, written in C.
[https://github.com/quiet/libcorrect](https://github.com/quiet/libcorrect)

Learning enough about finite fields to implement one is really mind bending.
Definitely recommend people try it, or at least make the encoder side

~~~
nickcw
It takes me back! I wrote my first one in Z80 assembler a looong time ago as
part of my first real job (~1990) which was used to error correct a satellite
channel (bandwidth about 19.2 Kbit/s IIRC)!

It used lots of table lookups to make things run at a reasonable speed, but
the tables couldn't be too big since there was only an 8K EEPROM. The Z80 code
only did d=3 codes (so could correct 1 error or detect two).

Working out how to solve a quadratic equation over GF(256) in Z80 assembler
was my personal highlight!

------
mcphage
Fun mathematical aside: if you have a polynomial with positive integral
coefficients, then you can uniquely determine it with only two points, no
matter the degree.

~~~
ghusbands
For those who want the trick:
[https://www.johndcook.com/blog/2012/03/27/polynomial-
trick/](https://www.johndcook.com/blog/2012/03/27/polynomial-trick/)

~~~
zokier
Okay, that took some thinking to figure _why_ it works. Basically, p(x) tells
the coefficients as long as x is bigger than any coefficient. This is easy to
test with the given example polynomial p(x) = 2 x³ + 4 x + 3, p(10) = 2043,
where you can see the coefficients plainly in base 10. But for example p(x) =
2x³ + 14x + 3 is ambiguous with p(10) = 2143. (edit: I feel like there is a
connection to Nyquist-Shannon theorem here, the coefficients get kinda
"aliased")

The trick here is that because p(1) is the sum of the coefficients, it must
also be bigger than any of coefficients, so p(p(1)) is always "safe" to use.

To avoid base conversions, I think you can always use next power of ten for
the second value, i.e. p(10^n) where n = floor(log10(p(1)))+1. For example if
p(1) = 182, then you could ask p(1000) = 12000140030 or 12 000 140 030, which
gives us the coefficients (12x³ + 140x + 30). Arguably easier than trying
figure out what 72368326 is in base 182.

~~~
mcphage
Yeah, I like the 10^n method, since it looks like you get the coefficients
written out very nicely.

------
nayuki
An explanation of Reed-Solomon ECC decoding, using field arithmetic and linear
algebra, with runnable code: [https://www.nayuki.io/page/reed-solomon-error-
correcting-cod...](https://www.nayuki.io/page/reed-solomon-error-correcting-
code-decoder)

------
0xdeadbeefbabe
> Your MP3 maybe got knocked down, but it got up again. You’d need to lose
> more than 4 pieces to keep it down.

Nice

~~~
yellowapple
I felt like the whole article was just a setup for that joke.

~~~
jtolds
it's easily the thing I'm most proud of

------
dmitrygr

      high-performance [...] Reed-Solomon
    

RS has not been the state of the art since, well, at least since BCH happened

~~~
nullc
RS codes are a sub-class of BCH codes, where the subfield and field are the
same.

RS codes, where they exist, achieve greater distance than BCH codes... but
they have a far more restricted set of parameters than BCH codes.

Many applications are moving to things other than BCH codes because even
though they are a much better class than RS codes they are still limited and
the existing BCH codes at many sizes are not as good as other kinds of codes.

------
tobz
Just had to say that this is probably the best explanation of Reed-Solomon
I've seen: practical explanations, useful visuals, good pacing, just enough
humor. :)

------
je42
fun stuff. wrote once a decoder from reading data tracks from cd in raw mode
:)

