Bias correction using histogram matching
user123
subbuuu at gmail.com
Fri Jan 4 14:35:58 CET 2013
I am trying to do the histogram matching of the simulated data to the observed data. The aim is to correct the bias in the simulated data by CDF matching CDFobs(y) = CDFsim(x). I could only reach to the stage of generating the CDFs. I got stuck in finding the transfer function.
The image shows the CDF's and the the Transfer function in plot(c)http://s8.postimage.org/4txybzz8l/test.jpg. I am trying to replicate the same. Please help me in achieving the plot.
Thanks in advance
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
import scipy.stats as st
sim = st.gamma(1,loc=0,scale=0.8) # Simulated
obs = st.gamma(2,loc=0,scale=0.7) # Observed
x = np.linspace(0,4,1000)
simpdf = sim.pdf(x)
obspdf = obs.pdf(x)
plt.plot(x,simpdf,label='Simulated')
plt.plot(x,obspdf,'r--',label='Observed')
plt.title('PDF of Observed and Simulated Precipitation')
plt.legend(loc='best')
plt.show()
plt.figure(1)
simcdf = sim.cdf(x)
obscdf = obs.cdf(x)
plt.plot(x,simcdf,label='Simulated')
plt.plot(x,obscdf,'r--',label='Observed')
plt.title('CDF of Observed and Simulated Precipitation')
plt.legend(loc='best')
plt.show()
More information about the Python-list
mailing list