Z-Test Statistic

MediumStatisticsMathArray

Description

Given a sample array, a hypothesized population mean, and the population standard deviation, return the one-sample z-statistic: (sample mean - population mean) / (population standard deviation / sqrt(n)). Round the result to 4 decimal places.

Examples

Input:[8,10,12], 10, 3
Output:0
Explanation:

The z-statistic measures how many standard errors separate the sample mean from the hypothesized population mean.

Input:[85,90,95,100], 80, 10
Output:2.5
Explanation:

The z-statistic measures how many standard errors separate the sample mean from the hypothesized population mean.

Input:[48,52,50,49,51], 50, 5
Output:0
Explanation:

The z-statistic measures how many standard errors separate the sample mean from the hypothesized population mean.

Constraints

  • 1 ≤ sample length ≤ 10⁴
  • population standard deviation > 0

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.