在MATLAB中估计直方图的偏度 [英] Estimating skewness of histogram in MATLAB
问题描述
我可以在MATLAB中进行哪些测试来测试直方图的扩展?例如,在给定的直方图中,我只对1,2,3,5和7(从左到右,从上到下)感兴趣,因为它们的分布较少.如何获得一个可以告诉我直方图是否正偏的值?
What test can I do in MATLAB to test the spread of a histogram? For example, in the given set of histograms, I am only interested in 1,2,3,5 and 7 (going from left to right, top to bottom) because they are less spread out. How can I obtain a value that will tell me if a histogram is positively skewed?
使用Chi-Squared测试可能是可行的,但是我不确定MATLAB代码将适用于什么.
It may be possible using Chi-Squared tests but I am not sure what the MATLAB code will be for that.
推荐答案
您可以使用标准偏度的定义.换句话说,您可以使用:
You can use the standard definition of skewness. In other words, you can use:
您可以计算数据的平均值,并使用上面的公式来计算偏斜度.正偏度和负偏度是这样的:
You compute the mean of your data and you use the above equation to calculate skewness. Positive and negative skewness are like so:
来源:维基百科
因此,值越大,偏斜度就越大.值越负,则歪斜度越大.
As such, the larger the value, the more positively skewed it is. The more negative the value, the more negatively skewed it is.
现在要计算直方图数据的平均值,这非常简单.您只需对直方图条目进行加权总和,然后除以条目总数即可.假设您的直方图存储在h
中,则直方图的bin中心存储在x
中,您可以执行以下操作.我在这里要做的是假设您具有从0到N-1
的bin,其中N
是直方图中的bin总数...从您的图片来看:
Now to compute the mean of your histogram data, it's quite simple. You simply do a weighted sum of the histogram entries and divide by the total number of entries. Given that your histogram is stored in h
, the bin centres of your histogram are stored in x
, you would do the following. What I will do here is assume that you have bins from 0 up to N-1
where N
is the total number of bins in the histogram... judging from your picture:
x = 0:numel(h)-1; %// Judging from your pictures
num_entries = sum(h(:));
mu = sum(h.*x) / num_entries;
skew = ((1/num_entries)*(sum((h.*x - mu).^3))) / ...
((1/(num_entries-1))*(sum((h.*x - mu).^2)))^(3/2);
skew
将包含遵循该公式的直方图的偏度的数值度量.因此,通过问题陈述,您将需要寻找正数和较大的偏度数.我不能真正评论您应该看什么阈值,但是要寻找比您拥有的大多数直方图大得多的正数.
skew
would contain the numerical measure of skewness for a histogram that follows that formula. Therefore, with your problem statement, you will want to look for skewness numbers that are positive and large. I can't really comment on what threshold you should look at, but look for positive numbers that are much larger than most of the histograms that you have.
这篇关于在MATLAB中估计直方图的偏度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!