2- I’m not sure I understand your question… Are you sure you haven’t gotten mixed up with your k values? i.e. was the plot that you shared above obtained with that random-looking k?. We can tell about the leading one’s presence just by observation; in the plots above, the sudden change around k index = 16 corresponds exactly with the position of the leading 1 in the k used to generate those plots. Moreover if you repeat the experiment with a different k, where you move around the leading 1 (but keeping all other bits the same, to make the change more obvious), you’ll see that the first “jump” always lines up with the location of the leading one.
3- As shown in the notebook, when we use a known k with easily identifiable patterns of 1’s and 0’s we obtain something like this:
and we simply manually set a threshold at the halfway point between the power metric for 1’s vs that of 0’s. The “initial threshold” business complicates this a little bit but it’s the same idea.