% This is a Wrapper Script for performing a test for the existence of  multi-modes 
% and multi-bumps in a given (magnitude) time-series. The function MM_MB is 
% executed for this purpose. The description of the fuction can be found in 
% comments within "MM_MB_V2_*.m" code. Here, the input data and the 
% parameters (i.e. the function's  arguments) are defined by the User. Please 
% modify the parameters in the script accordingly,the lines that can be modified 
% are followed  by a comment "- PLEASE SET". 
% PLEASE REFER ALSO TO APPLCATION DOCUMENTATION: 
% "READ_ME_App_2B_v2_Description_MM_MB.docx" 

clc;clear;
% STEP 1.  DATA Upload: 
cd Sample_Data                                                      % PLEASE Specify data directory path
M=dlmread('test_vector.txt');                                    % PLEASE SET data (magnitude) vector input file 
cd ../

% STEP 2.  Completeness Threshold Selection:
Mc=1.5;                                                                % PLEASE SET 
  
% STEP 3.  Number of points: 
m=100;                                                                 % PLEASE SET 
  
% STEP 4.  Bootstrap Iterations: 
n_boot=100;                                                          % PLEASE SET  

% STEP 5.  Initial h: 
h=0.01;                                                                 % PLEASE SET 

% STEP 6.  h step (dh):
delta_h=0.001;                                                       % PLEASE SET 

% STEP 7.  Method for MM testing:
MMmeth='Efron';                                                     % PLEASE SET 

% STEP 8.  Method for MB testing:
MBmeth='Silverman';                                                % PLEASE SET 

% STEP 9. RUN Function ['MM_MB']
[n,bval,Rmodes,hcrit_modes,Rbumps,hcrit_bumps,gau,gau_b,poch,poch2,zer1,zer2,x1,x2]=...
    MM_MB_V2_8(M,Mc,m,n_boot,h,delta_h,MMmeth,MBmeth);

% STEP 10. Optional, Plotting                                 % PLEASE Comment the next line to deactivate visualization
MM_MB_Plot(M,Mc,x1,x2,m,zer1,zer2,gau_b,poch,poch2);



