如何在 MATLAB 中计算 99% 的覆盖率?

发布于 2024-08-24 12:12:43 字数 71 浏览 3 评论 0 原文

我在 MATLAB 中有一个矩阵,我需要找到每一列的 99% 值。换句话说,99%的人口都比它大。 MATLAB中有这个功能吗?

I have a matrix in MATLAB and I need to find the 99% value for each column. In other words, the value such that 99% of the population has a larger value than it. Is there a function in MATLAB for this?

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

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

发布评论

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

评论(3

上课铃就是安魂曲 2024-08-31 12:12:43

使用 QUANTILE 函数。

Y = quantile(X,P);

其中 X 是矩阵,P 是标量或概率向量。例如,如果 P=0.01,则 Y 将是每列值的向量,因此 99% 的列值较大。

Use QUANTILE function.

Y = quantile(X,P);

where X is a matrix and P is scalar or vector of probabilities. For example, if P=0.01, the Y will be vector of values for each columns, so that 99% of column values are larger.

离线来电— 2024-08-31 12:12:43

最简单的解决方案是使用函数 QUANTILE 作为 yuk 建议

Y = quantile(X,0.01);

但是,您需要统计工具箱才能使用该函数QUANTILE。通过注意到 QUANTILE 调用函数PRCTILE,它本身调用内置函数INTERP1Q 进行主要计算。对于不包含 NaN 的二维矩阵的一般情况您可以使用以下代码计算每列的分位数:

P = 0.01;       %# Your probability
S = sort(X);    %# Sort the columns of your data X
N = size(X,1);  %# The number of rows of X
Y = interp1q([0 (0.5:(N-0.5))./N 1]',S([1 1:N N],:),P);  %'# Get the quantiles

这应该为您提供与调用 QUANTILE,无需任何工具箱。

The simplest solution is to use the function QUANTILE as yuk suggested.

Y = quantile(X,0.01);

However, you will need the Statistics Toolbox to use the function QUANTILE. A solution that is not dependent on toolboxes can be found by noting that QUANTILE calls the function PRCTILE, which itself calls the built-in function INTERP1Q to do the primary computation. For the general case of a 2-D matrix that contains no NaN values you can compute the quantiles of each column using the following code:

P = 0.01;       %# Your probability
S = sort(X);    %# Sort the columns of your data X
N = size(X,1);  %# The number of rows of X
Y = interp1q([0 (0.5:(N-0.5))./N 1]',S([1 1:N N],:),P);  %'# Get the quantiles

This should give you the same results as calling QUANTILE, without needing any toolboxes.

感性不性感 2024-08-31 12:12:43

如果您没有统计工具箱,则总有

y=sort(x);
y(floor(length(y)*0.99))

y(floor(length(y)*0.01))

取决于您的意思。

If you do not have the Statistics Toolbox, there is always

y=sort(x);
y(floor(length(y)*0.99))

or

y(floor(length(y)*0.01))

depending on what you meant.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文