Extracting numerical data for corrected data from CDF bias correction code
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone,
I found a code from the study of Singh et al (2020) (https://www.mathworks.com/matlabcentral/fileexchange/78784-cdf-matching-bias-correction-method-in-matlab)
I need to take the numerical values of the corrected data that this code gives me in CDF plot. Yet, unfortunately, I'm not so familiar with Matlab or coding stuff.
So, if you just told me what function included in the code or what part of the code gives me the numerical values of the corrected data in a tabular/table form.
Plus, if possible, would you share with me how I can conduct the quantile mapping method for my GCM results because the code of yours gives me corrected data up until the end of the observation period, being 2018 in my case.
Below is the code and in the attachment is the result that I get running the code in Matlab
%% Reading data
data=xlsread('aydinmgmprecmont2.csv'); %sample random data
Ref_data=data(:,1);
Biased_data=data(:,2);
bias=sum(Biased_data-Ref_data)/length(Biased_data); %Bias value before bais correction
%% CDF Matching (Eq. 1) of [2]
Prob_ref = Prob_data(Ref_data)'; %Query points
Prof_biased = Prob_data(Biased_data)'; %Sample points
Biased_interpolated= interp1q(Prof_biased,sort(Biased_data),sort(Prob_ref)); %1-D linear interpolation of biased data according to the reference data
% interp1q returns interpolated values of a 1-D function at specific query points using linear interpolation
n=3; %degree of the polynomial
p= polyfit(Biased_interpolated,sort(Ref_data)-Biased_interpolated, n); % Polynomial fitting between the biased data and difference of referenced and interpolated data.
Corrected_Data= polyval(p,Biased_data)+ Biased_data; % Evaluates the polynomial p at each point in Biased_data plus the Biased_data
bias_after=sum(Corrected_Data-Ref_data)/length(Corrected_Data); %Bias value after bais correction
%% Plotting
plot(sort(Ref_data), Prob_ref , 'k-', 'linewidth',1.5)
hold on
plot(sort(Biased_data),Prof_biased, 'k--','linewidth',1.5)
hold on
plot( sort(Corrected_Data),Prob_data(Corrected_Data), 'k:', 'linewidth',1.5)
xlabel('Variable')
ylabel('CDF')
leg=legend ('Reference data','Biased data','Corrected data');
set(leg,'location','best')
set(gcf,'color','white')

Thanks in advance
1 Kommentar
ABHILASH SINGH
am 29 Apr. 2021
Hello Gul,
The code that you are talking about belongs to my matlab repository. Please find the answer to your question below;
1. bias gives you the bias before bias correction. (A positive bias represent overestimation and a negative bias represent underestimation case)
2. bias_after gives you the reduced bias value after bias correction using the CDF matching approach.
3. Corrected_Data gives you the corrected bias value.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Climate Science and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!