%%HP: T(3)A(D)F(.);
@ WEIGHT2, Weighted (Grouped) Data Statistics, by Joseph K. Horn
DIR
  WTOT @ Weighted Total
    \<< \GSX*Y
    \>>
  WMEAN @ Weighted Mean
    \<< \GSX*Y \GSY /
    \>>
  WSDEV @ Weighted Sample Standard Deviation
    \<< \GSY \GSDAT OBJ\-> EVAL DROP 0 1 ROT
      START ROT SQ ROT * +
      NEXT OVER * \GSX*Y SQ - SWAP DUP 1 - * / \v/
    \>>
  WPSDEV @ Weighted Population Standard Deviation
    \<< WMEAN 1 \GS+ WSDEV \GS- DROP
    \>>
END
