How to analyze a distribution parameters?
1 view (last 30 days)
Show older comments
Hi,
I have a distribution of pixels (y) as a function of a parameter (x) where every y value (bin) is the total number of pixels at a given value of x. I'd like to analyze this distribution for mean, median, max, std, etc, and find the corresponding x values for these measurements. Anybody have a way to do this?
Thanks,
Avi
1 Comment
John D'Errico
on 2 Apr 2016
Please don't indent your paragraphs. That causes the entire paragraph to come out as one long line, which must be scrolled to read it. I removed the indentation for you.
Accepted Answer
Roger Stafford
on 2 Apr 2016
Edited: Roger Stafford
on 2 Apr 2016
I fail to see what the difficulty is here. If x is a vector containing all the values of the parameter in question, then y is a vector of all the corresponding pixel counts and y/sum(y) is a vector of the probabilities of each value of x. The mean value of x would then be:
m = sum(x.*y/sum(y))
The standard deviation would be:
s = sqrt(sum((x-m).^2*y/sum(y)))
3 Comments
Roger Stafford
on 2 Apr 2016
Edited: Roger Stafford
on 2 Apr 2016
@Muhammad: The coefficient of determination would depend on what statistical model you are trying to fit.
@Avigdor: As an addendum to the above answer, here is code for finding the statistical median:
[xs,p] = sort(x);
ys = y(p);
c = cumsum(ys/sum(ys));
f = find(c>=1/2,1,'first');
xmed1 = xs(max(f-1,1));
xmed2 = xs(f);
The statistical median is any number between xmed1 and xmed2.
The max is not a statistical entity. Just use matlab's 'max' function on x.
Muhammad Usman Saleem
on 2 Apr 2016
@Roger: if i am using mean , mean absolute error, correlation and want to find coefficient of determination in matlab then its formula?
More Answers (1)
Image Analyst
on 2 Apr 2016
You can simply do
meany = mean2(y);
mediany = median(y(:));
maxy = max(y(:));
stdDevy = std(y(:));
I don't see how x is involved. Your parameter "x" is basically the gray level and is not involved at all. If you want the range of "x", you can simply do
grayLevelRange = max(y(:)) - min(y(:)) + 1;
3 Comments
Image Analyst
on 2 Apr 2016
For some arbitrary histogram with bin heights all over the place, no bin will likely have the mean bin count. For example, let's say the bins had counts from 0 to 100,000. And let's say the mean bin height was 23,489.12343. Well, no bin has that since counts must be an integer. So let's say you round to 23,489. Well, there might be 5 or 10 or any number of bins with a count of 23,489. So which one(s) do you want? And why?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!