Population Variance

MediumStatisticsMathArray

Description

Given an array of numbers nums, return the population variance using the n denominator, rounded to 4 decimal places.

Examples

Input:nums = [2,4,6,8]
Output:5
Explanation:

Summing squared deviations from the mean and dividing by n gives 5.

Input:nums = [1,2,3,4,5]
Output:2
Explanation:

Summing squared deviations from the mean and dividing by n gives 2.

Input:nums = [7,7,7]
Output:0
Explanation:

Summing squared deviations from the mean and dividing by n gives 0.

Constraints

  • 1 ≤ nums.length ≤ 10⁴

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.