Averages/Root mean square

From Rosetta Code
Revision as of 07:57, 20 February 2010 by rosettacode>Paddy3118 (New task and Python solution.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Averages/Root mean square
You are encouraged to solve this task according to the task description, using any language you may know.

Compute the Root mean square of the numbers 1..10.

The root mean square is also known by its initial RMS (or rms), and as the quadratic mean.

The RMS is calculated as the mean of the squares of the numbers, square-rooted:

C.f. Averages/Pythagorean means

Python

<lang Python>>>> from math import sqrt >>> def qmean(num): return sqrt(sum(n*n for n in num)/len(num))

>>> numbers = range(1,11) # 1..10 >>> qmean(numbers) 6.2048368229954285</lang>