`[<<][math][>>][..]`
Sun Feb 16 19:10:37 EST 2020

## protocol analyzer

```Starting from 8 bit, how to find the logic levels?  Assume the levels
will not change, so start with constructing a histogram.  This will be
strongly bimodal.  How to find those modes?

The simplest approach would be to find the local maximum starting from
above and below.  Then pick the mid-point, and use a ST to convert it
to digital.

Now, what about 3-level?  E.g. I have a RS485 line that has an idle
state at say 2/3 between high and low.

Alternative:
- logaritmic histogram
- average (center of gravity)
- split based on center of gravity
- linear center of gravity for each
- midpoint

Different approach: given midpoint, compute variance of the 2
sections.  Minimize variance.  This can be done exhaustively.

This likely also works for 3-modal.

Another: hill-climbing from all initial conditions.

Another: 3-modal: find first 2 modes using left/right local maxima,
then bisect hillclimb until disctinct 3rd pops up.

the hill-climbing require smoothing.

Another: fit a single sine wave to a smoothed histogram.

https://en.wikipedia.org/wiki/Cluster_analysis

https://en.wikipedia.org/wiki/K-means_clustering
https://en.wikipedia.org/wiki/Voronoi_diagram

Forgot: for differential line, it is actually completely trivial.  By
analogy, setting the clusters manually also solves the problem.

```
`[Reply][About]`
`[<<][math][>>][..]`