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: null_model_dir_sign.m
    path of file: ./repos/EEGapp/EEGapp/custom_stuff/BCT/2017_01_15_BCT
    
    the code of the file until where you have to start completion: function [W0, R] = null_model_dir_sign(W,bin_swaps,wei_freq)
%NULL_MODEL_DIR_SIGN     Directed random graphs with preserved weight,
%                        degree and strength distributions
%
%   W0 = null_model_dir_sign(W);
%   W0 = null_model_dir_sign(W,bin_swaps);
%   W0 = null_model_dir_sign(W,bin_swaps,wei_freq);
%   [W0 R] = null_model_dir_sign(W,bin_swaps,wei_freq);
%
%   This function randomizes an directed network with positive and
%   negative weights, while preserving the degree and strength
%   distributions. This function calls randmio_dir_signed.m
%
%   Inputs: W,          Directed weighted connection matrix
%           bin_swaps,  Average number of swaps of each edge in binary randomization.
%                           bin_swap=5 is the default (each edge rewired 5 times)
%                           bin_swap=0 implies no binary randomization 
%           wei_freq,   Frequency of weight sorting in weighted randomization
%                           wei_freq must be in the range of: 0 < wei_freq <= 1
%                           wei_freq=1 implies that weights are sorted at each step
%                               (default in older [<2011] versions of MATLAB)
%                           wei_freq=0.1 implies that weights are sorted at each 10th step
%                               (faster, default in newer versions of MATLAB)
%
%   Output:     W0,     Randomized weighted connection matrix
%               R,      Correlation coefficients between strength sequences
%                           of input and output connection matrices
%
%   Notes:
%       The value of bin_swaps is ignored when binary topology is fully
%   connected (e.g. when the network has no negative weights).
%       Randomization may be better (and execution time will be slower) for
%   higher values of bin_swaps and wei_freq. Higher values of bin_swaps may
%   enable a more random binary organization, and higher values of wei_freq
%   may enable a more accurate conservation of strength sequences.
%       R are the correlation coefficients between positive and negative
%   in-strength and out-strength sequences of input and output connection
%   matrices and are used to evaluate the accuracy with which strengths
%   were preserved. Note that correlation coefficients may be a rough
%   measure of strength-sequence accuracy and one could implement more
%   formal tests (such as the Kolmogorov-Smirnov test) if desired.
%
%   Example usage:
%
%   %Create random directed weights matrix
%
%   W=randn(100);
%
%   %Compute one instance of null model (slow execution time):
%   %bin_swaps=5,   rewire each binary edge 5 times on average
%   %wei_freq=1,    sort all edges at every step
%
%   tic; [W0_slow R_slow]=null_model_dir_sign(W,5,1); R_slow, toc
%
%   R_slow =
%       0.9795    0.9724    0.9772    0.9773
%   Elapsed time is 3.485388 seconds.
%
%   %Compute another instance of of null model (fast execution time):
%   %bin_swaps=5,   rewire each binary edge 5 times on average
%   %wei_freq=0.1,  sort all edges at every 10th step (10=1/0.1)
%
%   tic; [W0_fast R_fast]=null_model_dir_sign(W,5,0.1); R_fast, toc
%
%   R_fast =
%       0.9655    0.9652    0.9717    0.9804
%   Elapsed time is 0.763831 seconds.
%
%
%   Reference: Rubinov and Sporns (2011) Neuroimage 56:2068-79
%

    
function [W0, R] = null_model_dir_sign(W,bin_swaps,wei_freq)
%NULL_MODEL_DIR_SIGN     Directed random graphs with preserved weight,
%                        degree and strength distributions
%
%   W0 = null_model_dir_sign(W);
%   W0 = null_model_dir_sign(W,bin_swaps);
%   W0 = null_model_dir_sign(W,bin_swaps,wei_freq);
%   [W0 R] = null_model_dir_sign(W,bin_swaps,wei_freq);
%
%   This function randomizes an directed network with positive and
%   negative weights, while preserving the degree and strength
%   distributions. This function calls randmio_dir_signed.m
%
%   Inputs: W,          Directed weighted connection matrix
%           bin_swaps,  Average number of swaps of each edge in binary randomization.
%                           bin_swap=5 is the default (each edge rewired 5 times)
%                           bin_swap=0 implies no binary randomization 
%           wei_freq,   Frequency of weight sorting in weighted randomization
%                           wei_freq must be in the range of: 0 < wei_freq <= 1
%                           wei_freq=1 implies that weights are sorted at each step
%                               (default in older [<2011] versions of MATLAB)
%                           wei_freq=0.1 implies that weights are sorted at each 10th step
%                               (faster, default in newer versions of MATLAB)
%
%   Output:     W0,     Randomized weighted connection matrix
%               R,      Correlation coefficients between strength sequences
%                           of input and output connection matrices
%
%   Notes:
%       The value of bin_swaps is ignored when binary topology is fully
%   connected (e.g. when the network has no negative weights).
%       Randomization may be better (and execution time will be slower) for
%   higher values of bin_swaps and wei_freq. Higher values of bin_swaps may
%   enable a more random binary organization, and higher values of wei_freq
%   may enable a more accurate conservation of strength sequences.
%       R are the correlation coefficients between positive and negative
%   in-strength and out-strength sequences of input and output connection
%   matrices and are used to evaluate the accuracy with which strengths
%   were preserved. Note that correlation coefficients may be a rough
%   measure of strength-sequence accuracy and one could implement more
%   formal tests (such as the Kolmogorov-Smirnov test) if desired.
%
%   Example usage:
%
%   %Create random directed weights matrix
%
%   W=randn(100);
%
%   %Compute one instance of null model (slow execution time):
%   %bin_swaps=5,   rewire each binary edge 5 times on average
%   %wei_freq=1,    sort all edges at every step
%
%   tic; [W0_slow R_slow]=null_model_dir_sign(W,5,1); R_slow, toc
%
%   R_slow =
%       0.9795    0.9724    0.9772    0.9773
%   Elapsed time is 3.485388 seconds.
%
%   %Compute another instance of of null model (fast execution time):
%   %bin_swaps=5,   rewire each binary edge 5 times on average
%   %wei_freq=0.1,  sort all edges at every 10th step (10=1/0.1)
%
%   tic; [W0_fast R_fast]=null_model_dir_sign(W,5,0.1); R_fast, toc
%
%   R_fast =
%       0.9655    0.9652    0.9717    0.9804
%   Elapsed time is 0.763831 seconds.
%
%
%   Reference: Rubinov and Sporns (2011) Neuroimage 56:2068-79
%
%
%   2011-2015, Mika Rubinov, U Cambridge

%   Modification History
%   Mar 2011: Original.
%   Sep 2012: Edge-sorting acceleration.
%   Dec 2015: Enforce preservation of negative degrees in sparse
%             networks with negative weights (thanks to Andrew Zalesky).

%#ok<*ASGLU>

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