reference
ttest_wizard.testRun.runTTest
Run one independent Welch, pooled, or paired t-test.
Syntax
result = ttest_wizard.testRun.runTTest(vectorA, vectorB, options)Description
Calculates one App-owned t-test with Base MATLAB beta functions. Difference direction is always A minus B. Scientific validation failures return a result row with ok=false and a stable status instead of fabricating a statistic.
Inputs
vectorA- Finite numeric vector with at least two values.
vectorB- Finite numeric vector with at least two values.
options- Scalar struct with method, alternative, alpha, labelA, and labelB. method accepts a label from testRun.choices or welch, pooled, or paired. alternative accepts a choice label or two_sided, greater, or less. alpha is a finite scalar strictly between zero and one.
Outputs
result- Scalar struct created by emptyResult. Successful results include vector snapshots, summaries, A-minus-B estimate and confidence bounds, standard error, t statistic, degrees of freedom, and p-value.
Units
A and B must use the same measurement unit. Means, standard deviations, the A-minus-B estimate, standard error, and confidence bounds retain that unit. The t statistic, degrees of freedom, and p-value are dimensionless.
Assumptions
Independent tests require observations that are independent within and between A and B. The pooled method additionally assumes equal population variances. The paired method requires displayed A(k) and B(k) to describe the same experimental unit; it analyzes A(k)-B(k). Test choice and independence remain the caller's scientific responsibility.
Failure Behavior
Invalid options throw ttest_wizard:InvalidTestOptions. Nonfinite vectors, sample sizes below two, unequal paired lengths, or zero standard error return ok=false with status invalid_input, insufficient_n, unequal_pairs, or zero_standard_error.
Example
options = struct( ...
"method", "welch", ...
"alternative", "two_sided", ...
"alpha", 0.05, ...
"labelA", "Condition A", ...
"labelB", "Condition B");
result = ttest_wizard.testRun.runTTest( ...
[1.2 1.4 1.3 1.5], [1.8 1.7 2.0 1.9 1.6], options);
assert(result.ok)Related APIs
ttest_wizard.testRun.runGroupTTests— Compare every group after the first with the first group.
Source
This page is generated from the MATLAB help text in apps/statistics/ttest_wizard/+ttest_wizard/+testRun/runTTest.m.