WEIGHT2, a better Weighted Statistics package, by Joseph K. Horn
Obsoletes the WEIGHT programs on Goodies Disk #7.

Ŀ
 Mini-instructions: Use the normal STAT functions to enter 
   all your [datum weight] pairs, then press:              
 WTOT to get the Weighted TOT (sum),                       
 WMEAN to get the Weighted MEAN (average),                 
 WSDEV to get the Weighted Sample Standard Deviation, and  
 WPSDEV to get the Weighted Population Standard Deviation. 


Background: When you have discrete data, the built-in MEAN and SDEV
functions suffice.  But they are unsatisfactory for data which have
different "weights" (that is, different levels of importance), or
different "frequencies" (that is, each datum occurs not just once, but
a different number of times).

The WEIGHT programs on Goodies Disk #7 assumed that the data
frequencies were small.  Meanwhile, Geir Atle Storhaug asked how to
handle extreme cases like this:

       DATUM   FREQUENCY
       -----   ---------
        1        9982
        1.5      8733
        2        8337
        2.5      1973
        3        1278

    Note: this data can either mean (1) you have only 5 data (namely
    1, 1.5, 2, 2.5, and 3), but the 1 is the most important, with a
    "weight" of 9982, and 3 is the least important, with a weight of
    only 1278; or (2) you have 30303 data, namely nine thousand nine
    hundred eighty two 1's, eight thousand seven hundred thirty three
    1.5's, and so on.  The real world problems in which such data
    arise might seem totally different.  They are mathematically
    identical, however.  Both are called "grouped data" in the
    literature, and the statistical equations are the same.

With huge frequencies like this, the WEIGHT program would fail.  It's
easy to see that the HP 48 cannot hold all these as discrete values in
a gargantuan DAT; it would require half a megabyte of RAM!  (Even if
it were possible, the HP48 would take forever to calculate the results
from such a huge DAT).  And the WEIGHT program assumed that weights
are always integers, which is not a reasonable assumption.

So here are new, improved MEAN and SDEV routines for weighted data,
and the nice thing is that you can enter your data exactly as shown
above: as [ DATUM  FREQUENCY ] pairs.  This way, the above example can
reside in a DAT that's only 95 bytes (!) and the results are fast.

Example:

    Enter the data shown above.

        WEIGHT             Puts you into the WEIGHT directory
        STAT  CL          Clears DAT
        [ 1  9982  +      Stores first [ datum weight ] pair
        1.5  8733  +
        2    8337  +
        2.5  1973  +
        3    1278  +      Stores last [ datum weight ] pair
        VAR                See the WEIGHT programs

    Find the total (sum) of the data:

        WTOT    --> 48522

    Find the mean (average) of the data:

        WMEAN    --> 1.60122760123

    Find the sample standard deviation of the data:

        WSDEV    --> .548539390967

    Find the population standard deviation of the data:

        WPSDEV    --> .548530339979
        
These programs run almost as fast as the built-in TOT, MEAN and SDEV,
and they're quite small, even though they're 100% User RPL.

Note: The WPSDEV program cannot be extracted from this directory and
used alone, because it requires the WMEAN and WSDEV programs.  The
other programs in this directory, however, can be extracted from the
directory and used as stand-alone programs.

-Joseph K. Horn-   -Peripheral Vision, Ltd.-
