Code covered by the BSD License  

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

» Watch video

Highlights from

4.8 | 5 ratings Rate this file 28 Downloads (last 30 days) File Size: 2.28 KB File ID: #18699 Version: 1.0
image thumbnail




11 Feb 2008 (Updated )

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

| Watch this File

File Information

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

Required Products Statistics and Machine Learning Toolbox
MATLAB release MATLAB 7.4 (R2007a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
30 Dec 2014 Markus Gschwind

@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!

Comment only
10 Nov 2014 Markus Gschwind

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!

14 Jun 2012 Pio Nonus

very useful indeed

03 Apr 2012 Carl Witthoft

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?

Comment only
01 Feb 2012 Mehdi Moghaddam

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

01 Feb 2012 Mehdi Moghaddam

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

Comment only
10 Nov 2011 Francisco de Castro

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

Comment only
10 Nov 2011 Mehdi Moghaddam

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

26 Aug 2008 Amor Keziou


Contact us