Complete the code to perform a t-test on sample data.
data = [5.1, 4.9, 5.0, 5.2, 5.3]; [h, p] = [1](data, 5);
The ttest function performs a one-sample t-test comparing the mean of data to the value 5.
Complete the code to perform a chi-square test on observed and expected counts.
observed = [20, 30, 50]; expected = [25, 25, 50]; [h, p] = chi2gof(1:length(observed), 'Ctrs', 1:length(observed), 'Frequency', [1], 'Expected', expected);
The 'Frequency' parameter requires the observed counts to compare against expected counts in the chi-square goodness-of-fit test.
Fix the error in the code to perform a two-sample t-test between two groups.
group1 = [5.1, 5.3, 5.2]; group2 = [4.9, 5.0, 5.1]; [h, p] = [1](group1, group2);
The ttest2 function performs a two-sample t-test comparing the means of two independent groups.
Fill both blanks to create a structure with counts and perform a chi-square test.
counts = [10, 15, 25]; expected = [15, 15, 20]; [h, p] = chi2gof([1], 'Frequency', [2], 'Expected', expected);
The first argument is the data points (categories), here 1 to length of counts. The 'Frequency' parameter is the observed counts.
Fill all three blanks to perform a paired t-test and display the p-value.
before = [5.1, 5.3, 5.2, 5.4]; after = [5.0, 5.1, 5.3, 5.5]; [h, p] = [1]([2], [3]); disp(p);
The ttest function with two inputs performs a paired t-test comparing before and after samples.
