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: compute_event_exceptionality.m
    path of file: ./repos/CaImAn-MATLAB/utilities
    
    the code of the file until where you have to start completion: function [fitness,erfc,sd_r,md] = compute_event_exceptionality(traces,N,robust_std)
%{
    Define a metric and order components according to the probabilty if some "exceptional events" (like a spike).

    
function [fitness,erfc,sd_r,md] = compute_event_exceptionality(traces,N,robust_std)
%{
    Define a metric and order components according to the probabilty if some "exceptional events" (like a spike).
    Suvh probability is defined as the likeihood of observing the actual trace value over N samples given an estimated noise distribution.
    The function first estimates the noise distribution by considering the dispersion around the mode.
    This is done only using values lower than the mode. The estimation of the noise std is made robust by using the approximation std=iqr/1.349.
    Then, the probavility of having N consecutive eventsis estimated.
    This probability is used to order the components.
 
    
    Parameters:
    -----------

    traces: array
        Fluorescence traces

 
    Returns:
    --------

    fitness: array
        value estimate of the quality of components (the lesser the better)

    erfc: array
        probability at each time step of observing the N consequtive actual trace values given the distribution of noise

    noise_est: array
        the components ordered according to the fitness

%}

T=size(traces,2);

md = max(mode_robust(traces, 2),0);

if ~exist('N','var'); N=5; end