Sample Variance
MediumStatisticsMathArray
Description
Given an array of numbers nums (length ≥ 2), return the sample variance using the (n - 1) denominator, rounded to 4 decimal places.
Examples
Input:
nums = [2,4,6,8]Output:
6.6667Explanation:
Summing squared deviations from the mean and dividing by n minus one gives 6.6667.
Input:
nums = [1,2,3,4,5]Output:
2.5Explanation:
Summing squared deviations from the mean and dividing by n minus one gives 2.5.
Input:
nums = [10,10,20]Output:
33.3333Explanation:
Summing squared deviations from the mean and dividing by n minus one gives 33.3333.
Constraints
- •
2 ≤ nums.length ≤ 10⁴