ram</span>
    <span class="comment">% positions</span>
    N = 50;

    <span class="comment">% Reshape data if required, e.g. if images are passed</span>
    sz = size(data);
    data = reshape(data,[sz(1) prod(sz(2:end))]);

    <span class="comment">% Calculate intensity</span>
    I = squeeze(sum(data,1));

    <span class="comment">% Number of repeats for each different intensity</span>
    n = length(I);

    <span class="comment">% The fraction of those points we need either side of the chosen pt</s