Averages/Root mean square: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) (Added 11l) |
|||
Line 1,780: | Line 1,780: | ||
=={{header|VBA}}== |
=={{header|VBA}}== |
||
Using Excel VBA |
|||
<lang vb> |
|||
Function |
<lang vb>Private Function root_mean_square(s() As Variant) As Double |
||
For i = 1 To UBound(s) |
|||
s(i) = s(i) ^ 2 |
|||
Next i |
|||
root_mean_square = Sqr(WorksheetFunction.sum(s) / UBound(s)) |
|||
End Function |
|||
Public Sub pythagorean_means() |
|||
Dim s() As Variant |
|||
s = [{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}] |
|||
Debug.Print root_mean_square(s) |
|||
End Sub</lang> |
|||
Without using Excel worksheetfunction: |
|||
<lang vb>Function rms(iLow As Integer, iHigh As Integer) |
|||
Dim i As Integer |
Dim i As Integer |
||
If iLow > iHigh Then |
If iLow > iHigh Then |
||
Line 1,803: | Line 1,815: | ||
6.20483682299543 |
6.20483682299543 |
||
</pre> |
</pre> |
||
=={{header|Wortel}}== |
=={{header|Wortel}}== |