$$ a_{i+1} = { a_i + b_i \over 2 } , \qquad b_{i+1} = \sqrt{a_i b_i} $$
@end tex
-@c @cindex Root-mean-square
-@c Another commonly used mean, the RMS (root-mean-square), can be computed
-@c for a vector of numbers simply by using the @kbd{A} command.
+@kindex u R
+@cindex Root-mean-square
+@tindex rms
+Another commonly used mean, the RMS (root-mean-square), can be computed
+for a vector of numbers by using the @kbd{u R}
+(@code{calc-vector-rms}) [@code{rms}]command.
@kindex u S
@pindex calc-vector-sdev
@r{ v@: H u M @: @: 19 @:vmedian@:(v)}
@r{ v@: I H u M @: @: 19 @:vhmean@:(v)}
@r{ v@: u N @: @: 19 @:vmin@:(v)}
+@r{ v@: u R @: @: @:rms@:(v)}
@r{ v@: u S @: @: 19 @:vsdev@:(v)}
@r{ v@: I u S @: @: 19 @:vpsdev@:(v)}
@r{ v@: H u S @: @: 19 @:vvar@:(v)}
(define-key calc-mode-map "uG" 'calc-vector-geometric-mean)
(define-key calc-mode-map "uM" 'calc-vector-mean)
(define-key calc-mode-map "uN" 'calc-vector-min)
+ (define-key calc-mode-map "uR" 'calc-vector-rms)
(define-key calc-mode-map "uS" 'calc-vector-sdev)
(define-key calc-mode-map "uU" 'calc-undo)
(define-key calc-mode-map "uX" 'calc-vector-max)
calc-roll-down-with-selections calc-roll-up-with-selections
calc-sel-error)
- ("calc-stat" calc-vector-op calcFunc-agmean
+ ("calc-stat" calc-vector-op calcFunc-agmean calcFunc-rms
calcFunc-vcorr calcFunc-vcount calcFunc-vcov calcFunc-vflat
calcFunc-vgmean calcFunc-vhmean calcFunc-vmax calcFunc-vmean
calcFunc-vmeane calcFunc-vmedian calcFunc-vmin calcFunc-vpcov
calc-vector-harmonic-mean calc-vector-max calc-vector-mean
calc-vector-mean-error calc-vector-median calc-vector-min
calc-vector-pop-covariance calc-vector-pop-sdev
-calc-vector-pop-variance calc-vector-product calc-vector-sdev
-calc-vector-sum calc-vector-variance)
+calc-vector-pop-variance calc-vector-product calc-vector-rms
+calc-vector-sdev calc-vector-sum calc-vector-variance)
("calc-store" calc-assign calc-copy-special-constant
calc-copy-variable calc-declare-variable
( ?G 1 calcFunc-vgmean )
( ?M 1 calcFunc-vmean )
( ?N 1 calcFunc-vmin )
+ ( ?R 1 calcFunc-rms )
( ?S 1 calcFunc-vsdev )
( ?X 1 calcFunc-vmax ) )
( ( ?C 2 calcFunc-vpcov )
:keys "I u M"
:active (>= (calc-stack-size) 1)
:help "The average (arithmetic mean) of the data values as an error form"]
+ ["rms(1:)"
+ (progn
+ (require 'calc-stat)
+ (call-interactively 'calc-vector-rms))
+ :keys "u R"
+ :active (>= (calc-stack-size) 1)
+ :help "The root mean square of the data values"]
["sdev(1:)"
(progn
(require 'calc-stat)
(calc-vector-op "meae" 'calcFunc-vmeane arg)
(calc-vector-op "mean" 'calcFunc-vmean arg)))))
+(defun calc-vector-rms (arg)
+ (interactive "P")
+ (calc-slow-wrapper
+ (calc-vector-op "rms" 'calcFunc-rms arg)))
+
(defun calc-vector-mean-error (arg)
(interactive "P")
(calc-invert-func)
suminvsqrwts))
(math-div (calcFunc-reduce '(var add var-add) means) len)))))))
+(defun calcFunc-rms (a)
+ "Return the root-mean-square of the vector A."
+ (math-sqrt
+ (calcFunc-vmean
+ (calcFunc-map '(var abssqr var-abssqr) a))))
+
(defun math-fix-int-intv (x)
(if (math-floatp x)
x