% This is a Wrapper Script for Performing the Anderson-Darling Test for testing 
% the hypothesis that a given time-series (e.g. magnitude) follows the exponential 
% or weibull distribution. The Matlab function "ADTestMag_v2_*.m" is executed for 
% this purpose.The description of the function can be found in the comments within 
% 'ADTestMag_V2_*.m' code. Here, the input data and parameters (i.e. arguments 
% of the Function) are defined by the User. Please modify 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
vector=dlmread('test_vector.txt');                              % PLEASE SET data (magnitude) vector input file 
cd ../

% STEP 2.  Minimum Vector Value Selection: 
Mmin=0.0;                                                             % PLEASE SET
  
% STEP 3.  Maximum Vector Value Selection: 
Mmax=5.0;                                                            % PLEASE SET

% STEP 4.  Parameter Round-off Interval: 
EPS=0.1;                                                               % PLEASE SET

% STEP 5.  Define number of Trials: 
trials=100;                                                            % PLEASE SET (interger)

% STEP 6.  Distribution Selection:
MTdistribution='exp';                                            % PLEASE SET ('exp' or 'weibul')

% STEP 7. RUN Function ['ADTestMag']
[pval, mmin, NN ,P ,S, bval]=ADTestMag_V2_8(vector,EPS,MTdistribution,Mmin,Mmax,trials);

% STEP 8. Optional: plotting results                        %PLEASE Comment next line to deactivate plotting
ADTestMag_Plot(vector,mmin,P,EPS,MTdistribution)



