Coefficient of Variation

MediumStatisticsMathArray

Description

Given an array nums of positive numbers, return the coefficient of variation (population standard deviation divided by the mean), rounded to 4 decimal places.

Examples

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

Dividing the population standard deviation by the mean gives 0.4472.

Input:nums = [10,12,14]
Output:0.1361
Explanation:

Dividing the population standard deviation by the mean gives 0.1361.

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

Dividing the population standard deviation by the mean gives 0.

Constraints

  • 1 ≤ nums.length ≤ 10⁴
  • mean(nums) > 0

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.