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: autoMI.m
    path of file: ./repos/mdembedding
    
    the code of the file until where you have to start completion: function ami = autoMI(x, nbins, maxlag)
    ami = zeros(maxlag+1,1);
    % Compute a histogram of x
    p_i = histcounts(x, nbins);
    % Normalize to make it a probability
    p_i = p_i / sum(p_i);
    % Save the original input vector
    xorig = x;
    % Loop over time lags from 0 to maxlag

    
function ami = autoMI(x, nbins, maxlag)
    ami = zeros(maxlag+1,1);
    % Compute a histogram of x
    p_i = histcounts(x, nbins);
    % Normalize to make it a probability
    p_i = p_i / sum(p_i);
    % Save the original input vector
    xorig = x;
    % Loop over time lags from 0 to maxlag
    for tau=0:maxlag
        % Make a time delayed version of x
        xtau = circshift(xorig,-tau);
        % Remove the last tau elements of this vector and of x
        xtau = xtau(1:end