Two-Sample Pooled T-Statistic
Description
Given two sample arrays, return the two-sample pooled t-statistic assuming equal variances: t = (mean1 - mean2) / sqrt(sp^2 (1/n1 + 1/n2)), where the pooled variance sp^2 = ((n1-1)s1^2 + (n2-1)s2^2) / (n1 + n2 - 2) and each s^2 is the sample variance with denominator (n - 1). Round the result to 4 decimal places.
Examples
[1,2,3], [4,5,6]-3.6742The pooled t-statistic compares the two sample means against their shared variability, pooling each group’s variance by its degrees of freedom.
[10,12,14], [11,13,15]-0.6124The pooled t-statistic compares the two sample means against their shared variability, pooling each group’s variance by its degrees of freedom.
[1,2,3,4], [2,3,4,5]-1.0954The pooled t-statistic compares the two sample means against their shared variability, pooling each group’s variance by its degrees of freedom.
Constraints
- •
2 ≤ each sample length ≤ 10⁴
Ready to solve this problem?
Practice solo and sharpen your skills for technical interviews.