

Functions 


Moments 


The
enumeration method computes the moments of the function
by enumerating all possible values of the random variables
and using probability theory to compute the moments. For
a discrete distribution with integer intervals, the evaluation
is exact. The formulas for the mean and variance of a
function of integerrandom variables are below.



To compute the mean and variance all possible values
of the variables are generated and the resultant sums are compiled.
We use the second form of the variance computation in the addin.
On selecting on the Moments command from the menu, the
addin presents the following dialog. 



The first field accepts
the name of a previously constructed function form. During the
enumeration, the Excel calculation mode is controlled by the
program. The Calculation frame of the dialog determines
when the workbook is calculated. For the Automatic option,
the workbook recalculates every time a cell is changed. This
is the default for most Excel users, but it may result in slow
computations when there are several random variables and the
number of combinations is very large. For the Worksheet
and Workbook options, the addin sets the calculation
mode to manual. Then after the complete variable vector
is constructed, the worksheet or workbook is calculated depending
on which option is chosen.
For the example case, the program computes the
total number in the set X and when that number
is greater than 1000 presents the number with an opportunity
to continue or not. 



After a few seconds, the enumeration
process is complete and the results are placed on the form. The
mean and variance are accurate in the example case, because the
entire probability space has been enumerated and there is no approximation
of the function values. The 1 in cell B13 indicates this. The
computed moments are in rows 17 and 18. 


Other Distributions 

The first example used the same distribution
for all random variables. Distributions are easily changed by
changing the distribution names and parameters as illustrated
below. The F_2 form was constructed in the manner of the first
example, but the parameters of the Binomial for the first two
random variables were changed on the worksheet. The third random
variable was changed to a Bernoulli distribution by inserting
"Bern" in cell L3. The single parameter for the Bernoulli
is placed in L4. Similarly, the fourth random variable was changed
to a Normal distribution by placing "Norm" in M3. The
mean and standard deviation parameters for the Normal are in M4
and M5, respectively. For most distributions, the first three
letters of the name are sufficient to identify the distribution
and the parameters are placed immediately below the distribution
names. Of course, the words placed in column I to identify the
parameters are no longer appropriate for the new distributions. 



Since the moments are computed
with a discrete enumeration process, functional values for continuous
distributions must be approximated.
The addin computes probabilities accurately,
but the function value for the interval is taken as the value
at the midpoint of the interval. The accuracy of the approximation
depends on the size of the interval (0.5 for the example Normal
distribution). Of course the results of the moments analysis
are also approximate.
Since the range of the Normal distribution is
infinite and the example considers only the range from 0 to
5, the enumeration does not cover the entire probability. Rather
we see 0.99404 in cell J13. The formulas below show how the
mean and variance are adjusted by the total probability. The
adjustment assumes probabilities of 0 outside the range.


Using the features described on
this page almost any function of random variables can be analyzed
to find its mean and variance. When the variables are discrete,
the enumeration results are accurate. When some of the distributions
are continuous, the results are approximate.
The number of computations required by the enumeration process
depends on the number of random variables, the range for each
and the intervals into which the range is divided. The total
number computations can be very large, perhaps too large for
reasonable computation times. An alternative to the enumeration
approach is the Monte Carlo simulation method discussed on the
next page. 


