pan class="n">z1</span><span class="o">-</span><span class="n">z0</span>
    <span class="n">z_diff_min_index</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">argmin</span><span class="p">(</span><span class="n">z_diff</span><span class="p">)</span>

    <span class="c1"># finding the best fit value ignoring outliers</span>
    <span class="n">b</span> <span class="o">=</span> <span class="mf">0.5</span><span class="o">*</span><span class="n">z0</span><span cl