在 MATLAB 中估计直方图的偏度 [英] Estimating skewness of histogram in MATLAB

查看:64
本文介绍了在 MATLAB 中估计直方图的偏度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 MATLAB 中做哪些测试来测试直方图的传播?例如,在给定的一组直方图中,我只对 1、2、3、5 和 7(从左到右,从上到下)感兴趣,因为它们的分布较少.如何获得一个值来告诉我直方图是否正偏斜?

可能可以使用卡方检验,但我不确定 MATLAB 代码是什么.

解决方案

您可以使用

因此,值越大,它的偏斜程度就越大.值越负,越负偏斜.

<小时>

现在计算直方图数据的平均值,非常简单.您只需对直方图条目进行加权求和,然后除以条目总数.鉴于您的直方图存储在 h 中,直方图的 bin 中心存储在 x 中,您将执行以下操作.我在这里要做的是假设你有从 0 到 N-1 的 bin,其中 N 是直方图中的 bin 总数......从你的图片来看:

x = 0:numel(h)-1;%//从你的图片来看num_entries = sum(h(:));mu = sum(h.*x)/num_entries;偏斜 = ((1/num_entries)*(sum((h.*x - mu).^3)))/...((1/(num_entries-1))*(sum((h.*x - mu).^2)))^(3/2);

skew 将包含遵循该公式的直方图的偏度数值度量.因此,在您的问题陈述中,您需要寻找正且大的偏度数.我真的无法评论您应该查看什么阈值,但请寻找比您拥有的大多数直方图大得多的正数.

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?

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:

Source: Wikipedia

As such, the larger the value, the more positively skewed it is. The more negative the value, the more negatively skewed it is.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆