MATLAB Answers


why does probplot return negative/larger than 1 values ?

Asked by Itzik Ben Shabat on 9 Oct 2015
Latest activity Commented on by Tom Lane
on 24 Oct 2015
is supposed to show the probability distrbution of the values in Y. so probability cant be negative or larger than 1 but if i check
it has both negative values and values larger than 1. how is that possible ? perhaps i misunderstood something?


Sign in to comment.

2 Answers

Answer by Walter Roberson
on 9 Oct 2015

get(h,'ydata') is going to return whatever data the routine needed to generate in order to plot nicely. If you look at the y axis locations you can see that the spacing is not nearly equidistant in probability value, with values being close together near the middle and further apart near the top or bottom.
A plausible explanation would be that the data stored is in terms of standard deviations from mean 0.5


hmmmm..... so I guess my question now actually becomes : is there a MATLAB function that gets a vector of observation data and return the probability distribution? if you know the probability distribution. If you do not know the probability distribution and want to find the "best" fit, then you would use other routines.
For a normal distribution, Walter is correct. The plot is constructed from standard normal values on the Y axis. The ticks are positioned and labeled, though, to indicate the probability values rather than the normal values. For instance, the tick mark labeled 0.75 is at the position where the plotted points have the value y=norminv(.75). Why all this? Because this construction (y values from standard normal) means that x data having a normal distribution with any mean or standard deviation will look roughly linear. If the points had been plotted with y data on the probability scale (rather than just labeled with those values), we would not have this simple linear relationship.

Sign in to comment.

Answer by Image Analyst
on 10 Oct 2015

In the Statistics and Machine Learning Toolbox:
[f,xi] = ksdensity(x,pts) returns a probability density estimate, f, for the sample in the vector x, evaluated at the specified values in vector pts. Here, the xi and pts vectors contain identical values.
[pdca,gn,gl] = fitdist(x,distname,'By',groupvar) creates probability distribution objects by fitting the distribution specified by distname to the data in x based on the grouping variable groupvar. It returns a cell array of fitted probability distribution objects, pdca, a cell array of group labels, gn, and a cell array of grouping variable levels, gl.


[f,xi] = ksdensity(x,pts)
seems to be the closest to what i need. Is there a functio that converts to probability instead of probability density ?
I am unclear as to the task here. Is it to figure out which probability distribution something is? Is it to estimate the probability distribution? Is it to assume that the data is already normally distributed and to figure out the probability of each sample relative to the known distribution?
If the task is to figure out which probability distribution something is, then you need to use one of the fitting routines.
If the task is to estimate the shape of the probability distribution, then ksdensity() is appropriate.
If the task is to figure out the probability of each sample relative to the known distribution then the cdf() function I linked to above is what should be used.
To give a probability, you'd have to give a range, like the probability you'll get a value between 0.42 and 0.43 or whatever. You can use the CDF for that like Walter says. Do you have such a range? Because the probability of an exact value is zero for continuous functions, though it is non-zero for discrete data sets like a quantized image of 256 gray levels.

Sign in to comment.