matlab:二维数据分箱

发布于 2024-12-22 13:15:48 字数 312 浏览 7 评论 0原文

我需要一些帮助来计算累积分布。

假设我有这样的数据:

data = abs(randn(1000,1));

我必须计算概率累积分布并将其分箱以减少点数。我这样做(让 bin = 50):

[n, x] = hist(data, 50);
y = cumsum(n);
y = y./max(y);

问题是,现在我有很多接近 y=1 的点,但只有少数接近零。我想要点的均匀分布(y 轴上的附加分箱?)。我希望你明白我的意思:) 我怎样才能做到这一点? 谢谢!

I need some help with calculating cumulative distribution.

lets say I have data like that:

data = abs(randn(1000,1));

I have to calculate probability cumulative distribution and bin it to reduce amount of points. I am doing it like that (lets take bin = 50):

[n, x] = hist(data, 50);
y = cumsum(n);
y = y./max(y);

The problem is, that now I have a lot of points close to y=1, but only few close to zero. I'd like to have kind of equal distribution distribution of points (additional binning on y axis?). I hope you know what I mean :) How I can do that?
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

握住我的手 2024-12-29 13:15:48

因此,这实际上意味着在您的 data 向量中,许多点都接近 0。通常的过程是使用 log:log2 或 log10 来转换数据,具体取决于数据的性质。

尝试

[n, x] = hist(log10(data), 50);
y = cumsum(n);
y = y./max(y);

您也可以尝试用 sqrt 代替 log 或其他函数。

更新

在发表评论后查看问题,我认为您想使用如下内容:

bin = 10.^(linspace(log10(min(data)),log10(max(data)),50));
[n, x] = hist(data, bin);
y = cumsum(n);
y = y./max(y);
plot(bin,y,'.')

So, it actually means that in your data vector many points are close to 0. The usual procedure is to transform the data using log: log2 or log10, depending on the nature of the data.

Try

[n, x] = hist(log10(data), 50);
y = cumsum(n);
y = y./max(y);

You can also try sqrt instead of log or other functions.

UPDATE

Reviewing the question after your comment I think you want to use something like this:

bin = 10.^(linspace(log10(min(data)),log10(max(data)),50));
[n, x] = hist(data, bin);
y = cumsum(n);
y = y./max(y);
plot(bin,y,'.')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文