title: How to efficiently mitigate "cycle bias"
body: <p>I am looping through the neighbors of a matrix element in order to find the smallest one as follows, while also saving its coordinates:</p>
  
  <pre><code>int minimum_r = curr_r; 
  int minimum_c = curr_c;
  uint8_t tmp_value = 255;
  
  for (int i = curr_r - 1; i &lt;= curr_r + 1; i++) {
      for (int j = curr_c - 1; j &lt;= curr_c + 1; j++) {
          uint8_t value = src[i * cols + j];
          if (value &lt; tmp_value) {
              tmp_value = value;
              minimum_r = i;
              minimum_c = j;
          }
      }
  }
  </code></pre>
  
  <p>The problem I am noticing is that if there are more than one minimum neighbors with same <code>value</code>, the first one to be checked will be selected. I remember reading about this "cycle bias" problem somewhere, but I can't recall the correct term for it.</p>
  
  <p>The snippet is from an algorithm to compute gradient descent, and I'm thinking that maybe I can mitigate the issue by finding the "sub-pixel" gradient. Am I missing a simpler solution here?</p>
  
  <p>Any suggestion is appreciated.</p>
  
  <p>EDIT:</p>
  
  <p>To be clear, my main question is:
  How is this programming issue referred to usually, if it is at all, so that I can look for it online (I remember reading about it before, and it was termed in a specific way).</p>