title: Elegant (most efficient) way to check whether the angle falls into the circular confidence interval
body: <p>I have the following sample dataset:</p>
  
  <pre><code>In [222]: df
  Out[222]:
      ci_low  circ_time_angle  ci_high
  0       30               30       30
  1       10                0       20
  2     -188              143      207
  3     -188                4      207
  4     -188                8      207
  5     -188               14      207
  6     -188              327      207
  7      242               57      474
  8      242              283      474
  9      242                4      474
  10    -190              200       -1
  11     -90              300        0
  12     -25               15       60
  13     -30              349      350
  14     420               30      600
  15    -100               23      719
  16    -100               23      259
  17    -350                5      -10
  18    -350               11      -10
  </code></pre>
  
  <p>where:</p>
  
  <ul>
  <li><code>ci_low</code> - is a lower bound of a circular confidence interval (CI)</li>
  <li><code>circ_time_angle</code> - is an angle that I want to check whether it falls into CI or not</li>
  <li><code>ci_high</code> - is an upper bound of a circular confidence interval (CI)</li>
  </ul>
  
  <p><strong>Constraints:</strong></p>
  
  <ul>
  <li><code>0 &lt;= circ_time_angle &lt;= 360</code></li>
  <li><code>ci_high &gt;= ci_low</code></li>
  <li><code>ci_low</code> and <code>ci_high</code> do <strong>NOT</strong> necessarily belong to <code>[0, 360]</code> (see rows <code>[2-18]</code> in the sample dataset).</li>
  </ul>
  
  <p><strong>Question:</strong> what would be the <em>elegant</em> way to check whether the angle <code>circ_time_angle</code> falls into circular confidence interval: <code>[ci_low, ci_high]</code>?
  Or do I need to check separately all the edge cases?</p>
  
  <p><strong>Desired / resulting dataset:</strong></p>
  
  <pre><code>In [224]: res
  Out[224]:
      ci_low  circ_time_angle  ci_high  falls_into_CI
  0       30               30       30           True
  1       10                0       20          False
  2     -188              143      207           True
  3     -188                4      207           True
  4     -188                8      207           True
  5     -188               14      207           True
  6     -188              327      207           True
  7      242               57      474           True
  8      242              283      474           True
  9      242                4      474           True
  10    -190              200       -1           True
  11     -90              300        0           True
  12     -25               15       60           True
  13     -30              349      350           True
  14     420               30      600          False
  15    -100               23      719           True
  16    -100               23      259           True
  17    -350                5      -10          False
  18    -350               11      -10           True
  </code></pre>
  
  <p>I also tried to convert CI boundaries to <code>[0, 360]</code> and to <code>[-180, 180]</code>, but it still didn't help me to find an elegant formula.</p>
  
  <hr>
  
  <p><strong>Sample dataset setup:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>data = {
  'ci_low': [30,
    10,
    -188,
    -188,
    -188,
    -188,
    -188,
    242,
    242,
    242,
    -190,
    -90,
    -25,
    -30,
    420,
    -100,
    -100,
    -350,
    -350],
   'circ_time_angle': [30,
    0,
    143,
    4,
    8,
    14,
    327,
    57,
    283,
    4,
    200,
    300,
    15,
    349,
    30,
    23,
    23,
    5,
    11],
   'ci_high': [30,
    20,
    207,
    207,
    207,
    207,
    207,
    474,
    474,
    474,
    -1,
    0,
    60,
    350,
    600,
    719,
    259,
    -10,
    -10]}
    
  df = pd.DataFrame(data)</code></pre>
  </div>
  </div>
  </p>