Created
April 11, 2012 01:31
-
-
Save mattjj/2356182 to your computer and use it in GitHub Desktop.
Q-Q plots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import numpy as np | |
import scipy.stats as stats | |
from matplotlib import pyplot as plt | |
def plot(data,cdf=stats.norm.cdf): | |
plt.figure() | |
plt.plot(np.cumsum(1./len(data) * np.ones(data.shape)),cdf(np.sort(data)),'bx') | |
plt.plot((0,1),(0,1),'r-') | |
plt.ylim((0,1)) | |
plt.xlim((0,1)) | |
plt.xlabel('empirical percentiles') | |
plt.ylabel('fit percentiles') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function qqplot(data,cdf) | |
if ~exist('cdf','var'), cdf=@normcdf; end | |
figure(); | |
hold on | |
plot(cumsum(1/length(data)*ones(size(data))),cdf(sort(data)),'bx'); | |
plot([0,1],[0,1],'r-'); | |
ylim([0,1]); | |
xlim([0,1]); | |
xlabel('empirical percentiles'); | |
ylabel('fit percentiles'); | |
hold off | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is good. I don't understand, why SciPy doesn't do QQ plots.