File Exchange

image thumbnail


version 1.0 (2.28 KB) by

GQQPLOT Display a generic Q-Q plot of sample vs. distribution



View License

GQQPLOT(X,DIST) makes an plot of the quantiles of the data set X versus the inverse of the cdf of a distribution specified in DIST, evaluated at probabilities equal to the quantiles of X. The parameters of the distribution are calculated from X.

The purpose of the QQ plot is to determine whether the sample in X is drawn from a given distribution. If it is, the plot will be linear. In the case of the Binomial distribution, an additional parameter is needed: N, number of trials, e.g. GQQPLOT(X,'binom',N).

The name of the distribution can be (case insensitive):

'norm' or 'normal'
'gam' or 'gamma'
'logn' or 'Lognormal',
'exp' or 'Exponential',
'wbl' or 'Weibull'.
'bin' or 'Binomial'
'ev' or 'Extreme Value',
'gev' or 'Generalized Extreme Value',
'gp' or 'Generalized Pareto',
'nbin' or 'Negative Binomial',
'poiss' or 'poisson'
'unif' or 'uniform'
'rayl' or 'rayleigh'

x= gamrnd(2,0.5,1000,1);
gqqplot(x,'normal') %Bad fit
gqqplot(x,'gamma') %Good fit

Comments and Ratings (9)

@Markus - just to follow up on this: The staircase shape is due to binned data when there are only few bins... Not a problem of gqqplot of course!
Thanks Francisco!

Great function!!! But I have on bizzare observation: The data I enter are sometimes and sometimes NOT strongly binned, i.e. a stairshape of the y-axis (empiric) data. I am not sure where this behavior comes from, and if it is possible to get rid of!

Pio Nonus

very useful indeed

Question: If I'm reading the code correctly, selecting e.g. a normal distribution causes the code to generate a reference distribution with a mean and sigma calculated from my input dataset. A QQplot should let me compare my normal distribution to a reference set with specified mean and sigma. If I'm wrong, please let me know; if I'm right, can you modify your code?

Francisco: I got it fixed and is working great...Had some nans in my data and I didn't notice.....cheers

there are electricity load data...they are totally 280514 records...missing data points and outliers have been removed...I just see an empty figure without any error message

Mehdi: Are there any errors? What's in your "large vectors"?

for small amount of data works very good..but it just show me an empty plain graph for large vectors!!

Amor Keziou


MATLAB Release
MATLAB 7.4 (R2007a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video