You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: analyze_average_expected_overlap.m
    path of file: ./repos/toolkit-legacy/analysis
    
    the code of the file until where you have to start completion: function [result] = analyze_average_expected_overlap(experiment, trackers, sequences, varargin)
% analyze_average_expected_overlap Performs expected overlap analysis and
% averaging
%
% Performs 
    
function [low, high] = find_range(p, density)

% find maximum on the KDE
[~, x_max] = max(p);
low = x_max ;
high = x_max ;

for i = 0:length(p)
    x_lo_tmp = low - 1 ;
    x_hi_tmp = high + 1 ;

    sw_lo = 0 ; sw_hi = 0 ; % boundary indicator
    % clip
    if x_lo_tmp <= 0 , x_lo_tmp = 1 ;  sw_lo = 1 ; end