function [rho]=rho_AvgSA_SA(Ts, T_r, M, Rjb, Fault_Type, Vs30)
% function to compute the correlation between Spectra acceleration and
% AvgSA.
% Done by Mohsen Kohragi.
% Last updated 06/12/2014
    rho=0;
for j=1:length(T_r)
    rho_bj = baker_jayaram_correlation(Ts, T_r(j));
    [~, sig1] = BA_2008_nga (M, T_r(j), Rjb, Fault_Type, Vs30);
    rho=(rho_bj*sig1)+rho;
end
[~, Avg_sig] = Sa_avg (M, T_r, Rjb, Fault_Type, Vs30) ;
rho = rho/(length(T_r)*Avg_sig);
end