t test and f test

5 ビュー (過去 30 日間)
Shahid
Shahid 2012 年 9 月 7 日
回答済み: Samayochita 2025 年 4 月 21 日
Hi, I am new to matlab. I have two vectors [2 3 5 4 2 1 4 6 ] and [2.7 3.1 4.2 1.7 1.1 3.7 5.2]. The individual values in the vector are independent of each other. So one of this is my calculated values set and other observed values test. Now I have to calculate p values for both t test and F test to do the error analysis. Can someone tell me which matlab functions should I use? Thanks.

回答 (1 件)

Samayochita
Samayochita 2025 年 4 月 21 日
Hi Shahid,
I understand that you are trying to calculate p-values for a t-test and an F-test between two independent data sets. A t-test and F-test can be performed in MATLAB using thettest (or “ttest2”) and “vartest2 functions respectively.
1. t-test (comparing means): Test if the means of two groups are significantly different.
In MATLAB ttest2is used for unpaired samples whilettest” is used for paired samples
Since the above data seems to be paired (calculated vs. observed for the same cases) thettest” function could be used:
[h, p_ttest] = ttest(A(1:length(B)), B);
fprintf('Paired t-test p-value: %f\n', p_ttest);
  • h is 1 if the test rejects the null hypothesis at the 5% significance level.
  • p_ttest is the p-value.
If your samples are not paired, use:
[h, p_ttest2] = ttest2(A(1:length(B)), B);
fprintf('Unpaired t-test p-value: %f\n', p_ttest2);
2. F-test (comparing variances): Test if the variances of two groups are significantly different.
[h, p_ftest] = vartest2(A(1:length(B)), B);
fprintf('F-test p-value: %f\n', p_ftest);
  • h is 0 if variances are statistically similar, 1 if they are significantly different
  • p_ftest is the p-value.
For more information, please refer to the MATLAB documentation links given below:

カテゴリ

Help Center および File ExchangeResults, Reporting, and Test File Management についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by