t test and f test
Afficher commentaires plus anciens
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.
Réponses (1)
Samayochita
le 21 Avr 2025
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 the “ttest” (or “ttest2”) and “vartest2” functions respectively.
In MATLAB “ttest2” is used for unpaired samples while “ttest” is used for paired samples
Since the above data seems to be paired (calculated vs. observed for the same cases) the “ttest” 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:
Catégories
En savoir plus sur Results, Reporting, and Test File Management dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!