Problem · Math

Test the Hypothesis

MediumPoint72OA

Given two arrays and a confidence level, determine whether the means of these series are significantly different using a two-tailed t-test. Additionally, output the magnitude by which the hypothesis passes or fails.

The magnitude is defined as the minimum absolute difference between the computed t-statistic and the t-statistic at the confidence level at the two tails.

Return an array with two values. The first element is "Yes" if the means are significantly different, or "No" if they are not. The second element is the magnitude rounded to 2 decimals.

For FastPrep's multi-language runner, return both values as strings, with the magnitude formatted to exactly two decimal places.

Source note: The screenshot has a tiny rounding/number typo in the samples, so FastPrep uses the mathematically consistent values while keeping the same t-test rules and source image visible below.

Function Description

Complete the function testHypothesis with the following parameters:

ParameterTypeDescription
nintthe number of data points
x[n]floatan array of data points
y[n]floatanother array of data points
confidence_levelfloatthe confidence level to test the hypothesis
Examples
01 · Example 1
n = 4
x = [4.461, 7.757, 17.317, 4.151]
y = [8.911, 12.68, -10.593, 17.048]
confidence_level = 0.95
return = ["No", "2.47"]

Performing a t-test at the 95% confidence level shows that the means are not significantly different, and the magnitude by which the null hypothesis passes is 2.47.

02 · Example 2
n = 10
x = [0.878, 2.817, 0.121, -0.945, -0.055, -1.456, 0.35, -1.478, -1.687, -1.889]
y = [1.142, -0.492, -0.988, -0.729, -0.846, -0.157, 0.5, 1.188, -1.075, -0.189]
confidence_level = 0.95
return = ["No", "1.82"]

Performing a t-test at the 95% confidence level shows that the means are not significantly different, and the magnitude by which the null hypothesis passes is 1.82.

More Point72 problems
drafts saved locally
public String[] testHypothesis(int n, float[] x, float[] y, float confidence_level) {
  // write your code here
}
n4
x[4.461, 7.757, 17.317, 4.151]
y[8.911, 12.68, -10.593, 17.048]
confidence_level0.95
expected["No", "2.47"]
checking account