Two-Sample Pooled T-Statistic

HardStatisticsMathArray

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

Input:[1,2,3], [4,5,6]
Output:-3.6742
Explanation:

The pooled t-statistic compares the two sample means against their shared variability, pooling each group’s variance by its degrees of freedom.

Input:[10,12,14], [11,13,15]
Output:-0.6124
Explanation:

The pooled t-statistic compares the two sample means against their shared variability, pooling each group’s variance by its degrees of freedom.

Input:[1,2,3,4], [2,3,4,5]
Output:-1.0954
Explanation:

The 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.