Averages/Root mean square: Difference between revisions

→‎{{header|Excel}}: Added a variant defining a reusable custom function
(Added Processing code)
(→‎{{header|Excel}}: Added a variant defining a reusable custom function)
Line 685:
 
=={{header|Excel}}==
===Cell reference expression===
If values are entered in the cells A1 to A10, the below expression will give the RMS value
<lang excel>
Line 691 ⟶ 692:
 
The RMS of [1,10] is then : 6.204836823 ( Actual displayed value 6.204837)
 
===LAMBDA===
 
In Excel builds equipped with the LAMBDA function, we can also rework the cell reference expression above to define a custom function, binding a name like ROOTMEANSQR to it in the workBook Name Manager:
 
(See [https://www.microsoft.com/en-us/research/blog/lambda-the-ultimatae-excel-worksheet-function/ LAMBDA: The ultimate Excel worksheet function])
 
{{Works with|Office 365 betas 2021}}
 
<lang lisp>ROOTMEANSQR
=LAMBDA(xs,
SQRT(SUMSQ(xs)/COUNT(xs))
)</lang>
 
For this test, we assume that the following generic lambda is also bound to the name ENUMFROMTO in the Name Manager:
 
<lang lisp>ENUMFROMTO
=LAMBDA(a,
LAMBDA(z,
SEQUENCE(1 + z - a, 1, a, 1)
)
)</lang>
 
{{Out}}
{| class="wikitable"
|-
|||style="text-align:right; font-family:serif; font-style:italic; font-size:120%;"|fx
! colspan="2" style="text-align:left; vertical-align: bottom; font-family:Arial, Helvetica, sans-serif !important;"|=ROOTMEANSQR( ENUMFROMTO( 1 )( 10 ) )
|- style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff;"
|
| A
| B
|- style="text-align:right;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 1
| style="text-align:right; font-weight:bold" |
| style="font-weight:bold" | [1..10]
|- style="text-align:right;"
| style="text-align:center; font-family:Arial, Helvetica, sans-serif !important; background-color:#000000; color:#ffffff" | 2
| style="text-align:right; font-weight:bold" | Root mean square
| style="background-color:#cbcefb;" | 6.2048368229954285
|}
 
=={{header|F Sharp|F#}}==
9,659

edits