Function: calcFunc-vmean
calcFunc-vmean is an autoloaded and byte-compiled function defined in
calc-stat.el.gz.
Signature
(calcFunc-vmean &rest VECS)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-stat.el.gz
;;; Return the arithmetic mean of the argument numbers or vectors.
;;; (If numbers are error forms, computes the weighted mean.)
(defun calcFunc-vmean (&rest vecs)
(let* ((split (math-split-sdev-vec (math-flatten-many-vecs vecs) nil))
(means (car split))
(wts (nth 1 split))
(len (1- (length means))))
(if (= len 0)
(math-reject-arg nil "*Must be at least 1 argument")
(if (and (= len 1) (eq (car-safe (nth 1 means)) 'intv))
(let ((x (math-fix-int-intv (nth 1 means))))
(calcFunc-vmean (nth 2 x) (nth 3 x)))
(math-with-extra-prec 2
(if (and wts (> len 1))
(let* ((sqrwts (calcFunc-map '(var mul var-mul) wts wts))
(suminvsqrwts (calcFunc-reduce
'(var add var-add)
(calcFunc-map '(var div var-div)
1 sqrwts))))
(math-div (calcFunc-reduce '(var add var-add)
(calcFunc-map '(var div var-div)
means sqrwts))
suminvsqrwts))
(math-div (calcFunc-reduce '(var add var-add) means) len)))))))