如何在Matlab中比较不同的分布均值与参考真值?
我将 4 个不同方法的生产 (q) 值存储在 4 个矩阵中。 4 个矩阵中的每一个都包含来自不同方法的 q 值,如下所示:
Matrix_1 = 1 row x 20 column
Matrix_2 = 100 rows x 20 columns
Matrix_3 = 100 rows x 20 columns
Matrix_4 = 100 rows x 20 columns
列数表示年数。 1 行将包含与 20 年相对应的生产值。矩阵 2、3 和 4 的其他 99 行只是不同的实现(或模拟运行)。所以基本上矩阵 2,3 和 4 的其他 99 行是重复情况(但由于随机数而不是精确值)。
将 Matrix_1
视为参考事实(或基本情况)。现在,我想将其他 3 个矩阵与 Matrix_1
进行比较,看看这三个矩阵(每个矩阵都有 100 次重复)中哪一个与 Matrix_1
比较得最好,或者最接近。
在 Matlab 中如何实现这一点?
我知道,我们手动使用置信区间 (CI),方法是绘制 Matrix_1 的均值
,并绘制 Matrix_2 的均值
、Matrix_3 的均值<的每个分布/code> 和
Matrix_4 的平均值
。矩阵 2、3 和 4 中包含参考真值(或 Matrix_1 的平均值)的最大 CI 将是答案。
mean of Matrix_1 = (1 row x 1 column)
mean of Matrix_2 = (100 rows x 1 column)
mean of Matrix_3 = (100 rows x 1 column)
mean of Matrix_4 = (100 rows x 1 column)
我希望这个问题很清楚并且与SO相关。否则,请随意编辑/建议任何有问题的内容。谢谢!
编辑:我谈到的三种方法分别是a1、a2和a3。这是我的结果:
ci_a1 =
1.0e+008 *
4.084733001497999
4.097677503988565
ci_a2 =
1.0e+008 *
5.424396063219890
5.586301025525149
ci_a3 =
1.0e+008 *
2.429145282593182
2.838897116739112
p_a1 =
8.094614835195452e-130
p_a2 =
2.824626709966993e-072
p_a3 =
3.054667629953656e-012
h_a1 = 1; h_a2 = 1; h_a3 = 1
这三种方法中,我的 CI 都不包含 mean ( = 3.454992884900722e+008)
。那么我们是否仍然考虑p值来选择最佳结果呢?
I have production (q) values from 4 different methods stored in the 4 matrices. Each of the 4 matrices contains q values from a different method as:
Matrix_1 = 1 row x 20 column
Matrix_2 = 100 rows x 20 columns
Matrix_3 = 100 rows x 20 columns
Matrix_4 = 100 rows x 20 columns
The number of columns indicate the number of years. 1 row would contain the production values corresponding to the 20 years. Other 99 rows for matrix 2, 3 and 4 are just the different realizations (or simulation runs). So basically the other 99 rows for matrix 2,3 and 4 are repeat cases (but not with exact values because of random numbers).
Consider Matrix_1
as the reference truth (or base case ). Now I want to compare the other 3 matrices with Matrix_1
to see which one among those three matrices (each with 100 repeats) compares best, or closely imitates, with Matrix_1
.
How can this be done in Matlab?
I know, manually, that we use confidence interval (CI) by plotting the mean of Matrix_1
, and drawing each distribution of mean of Matrix_2
, mean of Matrix_3
and mean of Matrix_4
. The largest CI among matrix 2, 3 and 4 which contains the reference truth (or mean of Matrix_1
) will be the answer.
mean of Matrix_1 = (1 row x 1 column)
mean of Matrix_2 = (100 rows x 1 column)
mean of Matrix_3 = (100 rows x 1 column)
mean of Matrix_4 = (100 rows x 1 column)
I hope the question is clear and relevant to SO. Otherwise please feel free to edit/suggest anything in question. Thanks!
EDIT: My three methods I talked about are a1, a2 and a3 respectively. Here's my result:
ci_a1 =
1.0e+008 *
4.084733001497999
4.097677503988565
ci_a2 =
1.0e+008 *
5.424396063219890
5.586301025525149
ci_a3 =
1.0e+008 *
2.429145282593182
2.838897116739112
p_a1 =
8.094614835195452e-130
p_a2 =
2.824626709966993e-072
p_a3 =
3.054667629953656e-012
h_a1 = 1; h_a2 = 1; h_a3 = 1
None of my CI, from the three methods, includes the mean ( = 3.454992884900722e+008)
inside it. So do we still consider p-value to choose the best result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:我误解了你的问题。请参阅 Yuk 的回答和以下评论。如果您想比较两个向量的分布而不是一个向量与单个值的分布,我的答案是您所需要的。显然,这里的情况就是后者。
关于您的 t 检验,您应该记住它们是针对“真实”均值进行检验的。给定每个矩阵的值的数量和置信区间,猜测结果的标准差并不难。这是对结果“传播”的衡量。现在,平均值的误差计算为结果的标准差除以观测值的数量。置信区间是通过将该标准误差乘以 appx 来计算的。 2.
该置信区间包含 95% 情况下的真实平均值。因此,如果真实均值正好位于该区间的边界处,则 p 值为 0.05,离均值越远,p 值越低。这可以解释为矩阵 2、3 或 4 中的值来自平均值与矩阵 1 相同的总体的机会。如果您看到 p 值,则可以说这些机会不存在。
因此,您会看到,当值的数量变多时,置信区间会变小,并且 t 检验变得非常敏感。这告诉您的只是三个矩阵与平均值显着不同。如果你必须选择一个,我无论如何都会看一下发行版。否则,最接近平均值的猜测似乎是一个不错的猜测。如果您想更深入地了解这一点,您还可以在 stats.stackexchange.com 上询问
您的问题和方法并不是很清楚:
现在,如果问题确实是分布的比较,您应该考虑查看 qqplot 的总体思路,并在 2-sample kolmogorov- smirnov test 用于正式测试。但请仔细阅读此测试,因为您必须了解它的作用才能正确解释结果。
旁注:如果您对多个案例进行此测试,请确保您了解多重比较的问题并使用适当的更正,例如。邦费罗尼或邓恩-西达克。
EDIT : I misinterpreted your question. See the answer of Yuk and following comments. My answer is what you need if you want to compare distributions of two vectors instead of a vector against a single value. Apparently, the latter is the case here.
Regarding your t-tests, you should keep in mind that they test against a "true" mean. Given the number of values for each matrix and the confidence intervals it's not too difficult to guess the standard deviation on your results. This is a measure of the "spread" of your results. Now the error on your mean is calculated as the standard deviation of your results divided by the number of observations. And the confidence interval is calculated by multiplying that standard error with appx. 2.
This confidence interval contains the true mean in 95% of the cases. So if the true mean is exactly at the border of that interval, the p-value is 0.05 the further away the mean, the lower the p-value. This can be interpreted as the chance that the values you have in matrix 2, 3 or 4 come from a population with a mean as in matrix 1. If you see your p-values, these chances can be said to be non-existent.
So you see that when the number of values get high, the confidence interval becomes smaller and the t-test becomes very sensitive. What this tells you, is nothing more that the three matrices differ significantly from the mean. If you have to choose one, I'd take a look at the distributions anyway. Otherwise the one with the closest mean seems a good guess. If you want to get deeper into this, you could also ask on stats.stackexchange.com
Your question and your method aren't really clear :
Now if the question is really the comparison of distributions, you should consider looking at a qqplot for a general idea, and at a 2-sample kolmogorov-smirnov test for formal testing. But please read in on this test, as you have to understand what it does in order to interprete the results correctly.
On a sidenote : if you do this test on multiple cases, make sure you understand the problem of multiple comparisons and use the appropriate correction, eg. Bonferroni or Dunn-Sidak.
如果我理解正确的话,MATLAB 中的计算是相当简单的。
步骤1-2(均值计算):
步骤3,使用HIST绘制分布直方图:
第 4 步。您可以进行 t 检验,将向量 2、3 和 4 与均值 k1_mean 和未知方差的正态分布进行比较。有关详细信息,请参阅 TTEST。
If I understand correctly the calculation in MATLAB is pretty strait-forward.
Steps 1-2 (mean calculation):
Step 3, use HIST to plot distribution histograms:
Step 4. You can do t-test comparing your vectors 2, 3 and 4 against normal distribution with mean k1_mean and unknown variance. See TTEST for details.