Bias correction using histogram matching

user123 subbuuu at
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)  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.title('PDF of Observed and Simulated Precipitation')

simcdf = sim.cdf(x)
obscdf = obs.cdf(x)
plt.title('CDF of Observed and Simulated Precipitation')

More information about the Python-list mailing list