You are on page 1of 40

DECS-433 Spreadsheet Skills

In all of your following courses, your professors will assume that you understand the
aspects and applications of Excel listed below. On the following tabs, I've collected
material from throughout the course which summarizes what you'll be expected to know.
As well, a few topics not on the "guaranteed-knowledge" list, but covered in our section,
are summarized for the sake of completeness.

Spreadsheet functions

=IF, =MAX, =MIN


=AND, =OR
=SUM, =COUNT, =AVERAGE, =PRODUCT
=SUMIF, =COUNTIF
=SUMPRODUCT
=COMBIN, =FACT
=LOOKUP
=BINOMDIST, =NORMDIST, =NORMINV, =TDIST, =TINV
=RAND, =RANDBETWEEN
=VAR, =STDEV

Spreadsheet tools

Data Table command


Solver

Simulation skills

=IF(RAND()<=p,1,0) simulates an event with probability p


=NORMINV(RAND(),mu,sigma) simulates a normally-distributed random variable
Familiarity with accumulating the results of spreadsheet simulation
The Basics: IF, MAX, MIN

The IF function lets a cell take either of two values, depending on whether a condition is
true or false: =IF(condition, value-if-true, value-if-false)

Name Score Grade


Fred 87 B
Mary 92 A
Todd 83 B After entering the formula in cell D7, to "apply" it to the
Alice 85 B rest of the students I could (1) click on D7 and then
Barack 98 A double-click the lower-right corner of the cell, (2) click
Hillary 93 A on D7 and drag the lower-right corner downwards, or
John 81 B (3) right-click on D7 and then select "Copy", highlight
Sarah 74 B D8:D14, right-click and select "Paste".

IFs can be nested to make more complex choices:

Name Score Grade


Fred 87 B #VALUE!
Mary 92 A
Todd 83 B Compound conditions such as "95<C19<=100" must
Alice 85 B be handled using the AND and/or OR functions:
Barack 98 A A+ #VALUE!
Hillary 93 A
John 81 B
Sarah 74 C

The MAX and MIN functions return the largest and smallest values in a range (or list of
ranges separated by commas).

98 #VALUE!
74 #VALUE! Note that cells containing non-numeric values are ignored.

The LARGE and SMALL functions extend these. For example, the third-largest of the
scores is
92 #VALUE!
and the second-smallest is
81 #VALUE!
Go, Cubs! (AND/OR White Sox!)

The Cubs are in the first round of the payoffs!

The playoff series will end when one team has won three games. The first two
games will be played "at home" in Chicago, the next one (or two, if needed) will
be played "on the road," and the final game - which will be played only if each
team wins two of the first four - will be back in Chicago.

You believe that the Cubs have a 60% chance of winning each home game,
and a 45% chance of winning each game on the road. (The outcome of each
game is independent of the outcomes of the other games.) Excel's AND function is "true" only whe
is true. =IF(AND(condition1, condition2
What is the probability that the Cubs will win the series? =IF(condition1, IF(condition2, a, b), b)

Simulation: (Tap 'F9' to rerun simulation.) #VALUE!

played? CC win? CC wins opp wins The OR function is "true" if at least one
Game 1 1 1 1 0 is true. =IF(OR(condition1, condition2),
Game 2 1 1 2 0 =IF(condition1, a, IF(condition2, a, b))
Game 3 1 1 3 0
Game 4 0 3 0 The cell below will be 1 only if the serie
Game 5 0 3 0
1 #VALUE!
3 games played
Both AND and OR can take more than
opp wins opp wins opp wins
CC win in CC win in CC win in
in 3 in 4 in 5
3 games 4 games 5 games
games games games
1 0 0 0 0 0

$B$30 $C$30 $D$30 $E$30 $F$30 $G$30 monitored cell


16.12% 8.74% 18.49% 18.68% 22.86% 15.11% mean
0.3676987 0.2823925 0.3882508 0.3897287 0.4199396 0.3581676 sample standard deviation
0 0 0 0 0 0 minimum
1 1 1 1 1 1 maximum
100,000 100,000 100,000 100,000 100,000 100,000 number of simulation runs
0.23% 0.18% 0.24% 0.24% 0.26% 0.22% margin of error (95% confidence)

57.47% Pr( Cubs win series )


D function is "true" only when every listed condition
AND(condition1, condition2), a, b) is equivalent to
on1, IF(condition2, a, b), b)

nction is "true" if at least one of the listed conditions


OR(condition1, condition2), a, b) is equivalent to
on1, a, IF(condition2, a, b))

ow will be 1 only if the series ends after three games.

and OR can take more than two conditions as arguments.


The Basics: SUM, COUNT, AVERAGE, PRODUCT

Consider the distances I (fictitiously) ran for exercise over the past 8 days. Note that I
took Sunday off.

Day Distance
Mon 1.50 15.250 #VALUE!
Tue 1.00 7.000 #VALUE!
Wed 0.75 2.179 #VALUE!
Thu 3.00 2.179 #VALUE!
Fri 2.00
Sat 5.00 All of these functions skip cells with non-numeric
Sun rested values (such as Sunday's distance).
Mon 2.00

Day Distance
Mon 1.50 15.250 #VALUE!
Tue 1.00 8.000 #VALUE!
Wed 0.75 1.906 #VALUE!
Thu 3.00 1.906 #VALUE!
Fri 2.00
Sat 5.00 Here, Sunday is counted.
Sun 0.00
Mon 2.00

I need to book three flights, from Chicago to Detroit, then New York, and
finally Washington DC.

flight
route
choices
ORD-DTW 5 60 #VALUE!
DTW-LGA 3
LGA-DCA 4 I have 60 itineraries to choose from.
SUMPRODUCT

The SUMPRODUCT function takes the product of the first elements in the specified
ranges, adds it to the product of the second elements, and so on:
SUMPRODUCT(range1, range2, …).

All of the ranges must be of the same shape (i.e., same numbers of rows and columns).

order
items unit price
quantity The total order cost is
widgets $1.25 1,000
wadgets $3.00 500 $3,650.00 #VALUE!
frumbles $0.75 1,200

Let X be a random variable with the distribution: x Pr(X=x)


1 20%
What is E[X] ? 2.75 2 15% #VALUE!
3 35%
4 30%

What is E[X2] ?

The probability distribution of z Pr(Z=z)


the random variable Z = X2 is 1 20%
4 15%
and therefore E[X2] is 8.75 9 35% #VALUE!
16 30%
Excel also allows us to do this
calculation directly from the
original distribution table: 8.75 #VALUE!

Notice that E[X2] is not the same as ( E[X] )2 . 7.5625 #VALUE!

This illustrates a very special property of the SUMPRODUCT function, which does not, in general,
carry over to other spreadsheet functions: You can do on-the-fly arithmetic on the numbers in
each range!

Taking advantage of this, we could compute the standard deviation of X in a single formula:

1.118034 #VALUE!
not, in general,
Birthdays (among 60 people)

person birthdate total with this birthdate


1 15-Feb 1
2 16-Nov 1 all Simulation
3 8-Dec 1 distinct number of people born on k-person date
4 11-Feb 1 dates? 1 2 3 4
5 9-Sep 1 0 48 12 0 0
6 30-Dec 1
7 22-Nov 1 $F$8 $G$8 $H$8 $I$8 $J$8
8 13-Sep 2 0.59% 51.02682 8.28614 0.65118 0.03408
9 16-Apr 1 0.07671 3.67981197 3.54294361 1.37525398 0.36894432
10 13-Nov 1 0 31 0 0 0
11 8-Jul 1 1 60 26 9 8
12 15-Mar 1 100,000 100,000 100,000 100,000 100,000
13 18-May 2
14 3-Feb 2
15 20-Dec 1 Here, we see uses of the COUNTIF function: =COUNTIF(range, criterion).
16 25-Mar 1 If the criterion is just a number, the function yields a count of the cells in the
17 8-Aug 1 range which take that value.
18 6-Dec 1
19 27-Oct 1 COUNTIF can also take either of two types of text criteria. Such criteria
20 14-Mar 1 must be in the form of a text string, contained in quotes.
21 8-Oct 1
22 23-Jan 1 If the criterion is simple text, COUNTIF counts the number of matching cells in
23 24-Apr 1 the range. 1 #VALUE!
24 12-Jan 1
25 1-Dec 1 The asterisk "*" (Shift-8) can be used as a wildcard.
26 22-May 1 2 #VALUE!
27 24-Feb 1
28 7-Mar 1 If the criterion is a numeric condition, COUNTIF counts the cells satisfying the
29 30-Aug 1 6 #VALUE!
30 29-May 1
31 27-Feb 1
32 16-Sep 2 order order
33 12-Mar 1 date cost
34 21-Apr 1 Fred 1/2/2008 $120 1
35 7-Nov 1 Mary 3/12/2008 $150 1
36 2-Aug 1 Bob 9/1/2007 $70 0
37 18-Nov 1 Ellen 1/3/2009 $200 0
38 21-Dec 1 Fred 3/20/2007 $180 0
39 18-May 2 George 4/12/2008 $100 1
40 15-Sep 1
41 11-Jun 2 date
42 16-Jun 1 range
43 16-Jul 1
44 11-Jun 2 There's a similar SUMIF function: =SUMIF(range, criterion, sum-range)
45 25-Dec 2
46 24-Jun 1 $300 #VALUE!
47 28-Jan 1 $530 #VALUE!
48 13-Sep 2
49 25-Dec 2 Both COUNTIF and SUMIF are limited to testing for a single criterion. If
50 5-May 1 you need to test for multiple criteria (for example, orders placed in 2008),
51 13-Mar 1 you have two approaches:
52 18-Jul 1
53 5-Dec 1 Add a new logical column to your data:
54 3-Feb 2
55 20-Feb 1 3 #VALUE!
56 26-Dec 1 $370 #VALUE!
57 4-Apr 1
58 18-Mar 1 Use array formulae:
59 5-Aug 1
60 16-Sep 2 3 #VALUE!
$370 #VALUE!

(When doing arithmetic with logical conditions, TRUE evaluates to 1, and


FALSE evaluates to 0.)
Simulation
ple born on k-person date
5 6 more k
0 0 0 people

$K$8 $L$8 $M$8 monitored cell


0.0016 0.00018 0 mean
0.08942885 0.03286302 0 sample standard deviation
0 0 0 minimum
5 6 0 maximum
100,000 100,000 100,000 number of simulation runs

COUNTIF(range, criterion). #VALUE!


a count of the cells in the (count people born on 2-person dates)

#VALUE!
criteria. Such criteria (count people with the same birthday)

number of matching cells in

"minimum" and "maximum" both match

unts the cells satisfying the condition.

#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

1/1/2008 #VALUE!
12/31/2008 #VALUE!

e, criterion, sum-range)

orders placed by Fred


orders of at least $150
or a single criterion. If
orders placed in 2008),

number of orders in 2008


total cost of orders in 2008

both entered by
typing Ctrl+Shift+Enter

UE evaluates to 1, and
Three Useful "Counting" Formulas

The FACTorial function 10 n


3,628,800 #VALUE!

The function =FACT(n) counts the number of ways n distinct


items can be arranged in a row.

FACT(n) = n! = 1·2·3·...·n .

Conventionally, FACT(0) = 1 ; there is precisely one way


to arrange "nothing."

The PERMUTations function 6 n


2 k
30 #VALUE!

The function =PERMUT(n,k) counts the number of ways to select k items -


in sequence, where order matters - from a group of n distinct items.

PERMUT(n,k) = n! / (n-k)! = n·(n-1)·…·(n-k+1) .

The COMBINations function 6 n


2 k
15 #VALUE!

The function =COMBIN(n,k) counts the number of ways to select k items -


as an unordered collection - from a group of n distinct items.

COMBIN(n,k) = PERMUT(n,k) / k! = n! / [(n-k)!·k!] = n·(n-1)·…·(n-k+1) / k! .

Note:

For documentation purposes, I used the following simple "macro" function


in column F:

Function ShowFormula(C As Variant) As Variant


Application.Volatile
ShowFormula = C.Formula
End Function

To add this function to a spreadsheet, select "Tools / Macro / Visual Basic Editor,"
then "Insert / Module," and then copy/paste the four lines above into the window
that opens. After doing this, close the Visual Basic Editor window, and the
function =showformula(cell address) is ready for use throughout your
spreadsheet.
Generating Random Numbers

Excel has two built-in random-number-generating functions: =RAND() and


=RANDBETWEEN(j,k).

=RAND() takes a random value, equally likely to be anywhere between 0 and 1. Each
time the spreadsheet is recalculated, a new random value is drawn.

Pressing the [F9] key in Excel forces a recalculation of your spreadsheet.

0.134524 =RAND(). Press [F9] a few times, and watch this change.

=RANDBETWEEN(j,k) takes a random value, equally likely to be any whole number


between j and k.

1 j
6 k
2 =RANDBETWEEN(j,k)

Press [F9] a few more times to convince yourself that the cell above is perfectly
simulating the roll of a single six-sided die!

We can use the RAND function to generate random events:

60% Pr(event occurs)


1 #VALUE!

This will be 1 if the event occurs, and 0 otherwise.


The LOOKUP function

The function =LOOKUP(value, lookup-range, result-range) looks for "value" in the


"lookup-range," and returns the corresponding entry in the "result-range." It
expects the entries in the lookup-range to be in increasing order, and if the value
isn't found, it selects the last entry in the lookup-range which is less than the
sought-for value.

Here's the IRS 2008 Individual tax table:

taxable income taxes


from … to … paid on excess plus
$0.00 $8,025.00 10% $0.00
$8,025.00 $32,550.00 15% $802.50
$32,550.00 $78,850.00 25% $4,481.25
$78,850.00 $164,550.00 28% $16,056.25
$164,550.00 $357,700.00 33% $40,052.25
$357,700.00 35% $103,791.75

$100,000.00 taxable income

$16,056.25 #VALUE!
$78,850.00 #VALUE!
28% #VALUE!

$21,978.25 taxes #VALUE!

The formula in cell B23 looks in the range B13:B18 for the value $100,000. The last
entry less than or equal to this is the fourth, so the fourth entry in E13:E18 is
returned. The formula in cell B24 shows a variant of the LOOKUP function: If the
result-range is not specified, it's assumed to be the same as the lookup-range.
Generating Discrete Random Variables

Given a probability distribution in table form, by adding a column for the cumulative
distribution we can simulate draws from the given distribution.

cumulative
distribution Pr(X≤x)
x Pr(X=x) 0%
Here's a simulated 10 20% 20%
draw from the 15 15% 35%
distribution: 30 40% 75%
35 25% 100%

30 #VALUE!

Notice the offset in the two ranges: If, for example, RAND() takes the value 0.4527, the
third value in the range D9:D12 (35%) is the final entry which is less than or equal to
0.4527, and therefore the third value in the range F8:F11 (30) is returned.

The same value (30) will be returned whenever RAND() is at least 0.35 and less than 0.75,
i.e., 40% of the time.

There's an alternative form of the LOOKUP function that does this directly:

30 #VALUE!

Note the braces, and the semicolon separating the lookup-range from the result-range.
Probability Distributions

Probability Tools in Excel

A number of Excel's built-in functions are useful for working with problems involving
uncertainty. Several of these deal with specific probability distributions.

=BINOMDIST(number_s,trials,probability_s,cumulative)

The probability of 2 successes in five independent trials, when the probability of success
in any one trial is 0.25, is

0.263672 #VALUE!

The probability of 0, 1, or 2 succeses is

0.896484 #VALUE!

=NORMDIST(x,mean,standard_dev,cumulative)

The probability that a normally-distributed random variable with mean 100 and standard
deviation 60 is less than or equal to 125 is

0.661539 #VALUE!

=NORMINV(probability,mean,standard_dev)

To capture 60% of that normal distribution in the left tail, stand at

115.2008 #VALUE!

=NORMSDIST(z)
=NORMSINV(probability)

These tacitly assume a mean of 0 and standard deviation of 1, i.e., the "standard"
normal distribution.

=EXPONDIST(x,rate,cumulative)

The probability that you'll see a telephone call hit the switchboard in the next 5 minutes,
given that you receive 8 calls per hour, is

0.486583 #VALUE! (with units = "minutes")


0.486583 #VALUE! (with units = "hours")

=POISSON(x,mean,cumulative)

The probability of receiving exactly 6 phone calls during the hour is

0.122138 #VALUE!

The probability of receiving 6 or fewer calls is

Page 16
Probability Distributions

0.313374 #VALUE!

Page 17
c u m u la t iv e p ro b a b ility Generating a Normally-Distributed Random Variable

Generating a Normal Random Variable


(expected value = 1000, std.dev. = 250)
100%

80%

60%

40%

20%

0%

Series1 value

Run
Positions on the vertical axis are generated (uniformly) at random.
The corresponding positions on the horizontal axis are normally distributed.

The Excel function that does this is: =NORMINV(RAND(),1000,250)


Conditional Normals

Expected Value of a Conditional Normal Variate

E[normal random E[normal random


z variable variable
| value is ³ z] | value is £ z]
-5 0.000001 -5.186504 formulas in this row
-4 0.000134 -4.225607
-3 0.004438 -3.283099
-2 0.055248 -2.373216 m =0
-1 0.287600 -1.525135 s =1
0 0.797885 -0.797885
1 1.525135 -0.287600 E( Z | Z ≥ z ) =mu+sigma^2*NORMDIST(z,mu,sigm
2 2.373216 -0.055248 E( Z | Z £ z ) =mu-sigma^2*NORMDIST(z,mu,sigma
3 3.283099 -0.004438
4 4.225607 -0.000134
5 5.186504 -0.000001 Example:

In most of the examples we've analyzed, we've assumed that any randomness I have 1200 units of stock on hand, an
is uniform, i.e., that unknown quantities are equally likely to take any value Weekly demand is normally distributed
between specified lower and upper limits. This assumption, while a touch deviation of 150.
unrealistic, has enabled us to work through the examples and extract the key
conceptual points without needing to worry about complex calculations. If I run out, what is the expected numb

A more realistic assumption would be that the uncertainty we face is normally 9.12%
distributed. If this were the case, we would find ourselves occasionally 1269.72
needing to compute conditional expectations in one tail of the normal 69.72
distribution. (Such computations arise in problems running the gamut from
adverse selection to inventory analysis: given that our offer is accepted, …, or
given that we stock out, … .) If I don't run out, what's the expected
next order comes in?
The formulas used to determine the second and third columns of the table given
here aren't pretty - but they do work for values of z between -5 and 5. (A wide 90.88%
enough range for all practical purposes.) 972.93
227.07

As expected, 1269.72 * 9.12% + 972.8

That is,

E[demand | demand ≥ 1200] * Pr(dem


+ E[demand | demand

Page 19
Conditional Normals

mu+sigma^2*NORMDIST(z,mu,sigma,FALSE)/(1-NORMDIST(z,mu,sigma,TRUE))
mu-sigma^2*NORMDIST(z,mu,sigma,FALSE)/NORMDIST(z,mu,sigma,TRUE)

ave 1200 units of stock on hand, and my next shipment will arrive in a week.
eekly demand is normally distributed, with a mean of 1000 and a standard
viation of 150.

run out, what is the expected number of units of unsatisfied demand I'll face?

Pr(demand ≥ 1200)
E[demand | demand ≥ 1200]
E[shortage | I run out]

don't run out, what's the expected number of items I'll have on hand when the
xt order comes in?

Pr(demand £ 1200)
E[demand | demand £ 1200]
E[surplus | I don't run out]

expected, 1269.72 * 9.12% + 972.83 * 90.88% = 1000 #VALUE!

demand | demand ≥ 1200] * Pr(demand ≥ 1200)


E[demand | demand £ 1200] * Pr(demand £ 1200) = E[demand] .

Page 20
Statistical Functions

Excel's normal distribution and t-distribution functions are not consistently


defined. While NORMDIST and NORMINV are both left-tail oriented, TDIST is
right-tail oriented and TINV is two-tail oriented.

1000 mean
200 standard deviation
900 target
30.8538% #VALUE!
Pr(normally-distributed random variable with given mean and
standard deviation is less than or equal to target value)

1000 mean
200 standard deviation
95.0000% target left-tail probability
1328.97 #VALUE!
value that a normally-distributed random variable with given mean
and standard deviation has "target probability" of being less than
or equal to

9 degrees of freedom
1.5 target value (must be non-negative)
8.3925% #VALUE!
Pr(t-distributed random variable with given number of degrees of
freedom [and with mean 0 and standard deviation 1] is greater
than or equal to target value)

9
5.0000% target two-tail probability
2.2622 #VALUE!
value that the absolute value of a t-distributed random variable with
given number of degrees of freedom has "target probability" of
exceeding

Excel offers functions for computing the variance and standard deviation of a
"population" of values, and a matching set of functions for using sample
values to estimate a population's variance and standard deviation.

1.0
2.0 a range of sample data
3.0
4.0

2.5000 #VALUE! population and sample mean sum of observations, divided by "n"
1.2500 #VALUE! population variance sum of squared differences from the mean, divided by "n"
1.1180 #VALUE! population standard deviation square root of population variance
1.6667 #VALUE! sample variance sum of squared differences from the mean, divided by "n-1"
1.2910 #VALUE! sample standard deviation square root of sample variance
Data Tables

Suffering through Dry Holes (and notes on "data tables")

A Bayesian approach can be used to revise probabilities that a prospect field will
produce oil (Oil & Gas Journal, January 11, 1988). In one case, geological
assessment indicates a 25% chance that the field will produce oil. Further, there is
an 80% chance that a particular well will strike oil, given that oil is present in the
prospect field.

Suppose that one well is drilled on the field and comes up dry. What is the
probability that the prospect field will produce oil?

If two wells come up dry, what is the probability that the field will produce oil?

The oil company would like to keep looking as long as the chances of finding oil
are greater than 1%. How many dry wells must be drilled before the field will be
abandoned?

25% Pr( oil really there) 2


25%·(20%)
20% Pr( dry hole | oil there ) 2 dry
2 k (number of test wells drilled ) ¬ vary this 2
(20%)

4.00% Pr( k consecutive dry holes | oil there ) else


100.00% Pr( k consecutive dry holes | NOT oil there ) oil
76.00% Pr( k consecutive dry holes ) at least 1 wet else
25%
1.00% Pr( k consecutive dry holes & oil there )
75.00% Pr( k consecutive dry holes & NOT oil there ) 75%
76.00% Pr( k consecutive dry holes )
no oil
2 dry
1.316% Pr( oil there | k consecutive dry holes ) 75%
100%

1.316% In the box to the left is an Excel "data table". Data tables
0 25.000% provide a quick way to see how a speadsheet result varies as
1 6.250% some parameter of the problem is varied.
2 1.316%
3 0.266% I wanted to tabulate values that would appear in cell B30 as
4 0.053% the number entered in cell B20 took different values.

To do this, I put the formula "=B30" in cell C33. In the column


immediately to the left, starting one row down (i.e., starting at
B34), I listed values that I wanted to successively plug into
cell B20 (the values 0, 1, 2, 3, and 4).

Then I highlighted the rectangle B33:C38, i.e., the entire


boxed-in range of cells.

Finally, I selected Data / Table from the menu. The menubox to


the right appeared.
(This is just a picture, not the actual menu.)

Page 23
Data Tables

I clicked in "Column input cell", then clicked cell B20 and "OK."

Excel filled in my table: If you click on any of cells C34:C38,


you'll see the "formula" {=TABLE(,B20)} .

This formula instructs Excel, each time it recalculates my In Excel 2007, select Data, (
spreadsheet, to successively put each value in the first Data Table to get here.
column of the table into cell B20, and record the resulting value
from C33 (really, from B30) in the second column of the table.

Notes:

The table is "live." This means that you can change any of
the first-column inputs and the table will update itself
automatically: Try putting a "4" in cell B34, for example.

You can also change the formula being tabulated. Try


changing cell C33 to "=B24" as an example. Or try entering
"=1+B20^2". 0
1
Tables can have more than one tabulated formula: In the 2
example to the right, I've tabulated all three of the formulas 3
just mentioned 4

If you want a horizontal table, just click on the "Row input cell"
box instead. 1.316%

And finally, if you want to track the changes in a single cell as 1.316%
the values in two other cells are varied, put the formula to be 0
tabulated in the upper-lefthand corner of the "table rectangle", 1
and give both row (B18) and column (B20) inputs: The table to 2
the right shows how our hopes of finding oil vary with both our 3
initial beliefs and our exploratory-well experiences. 4

Page 24
Data Tables

2 oil is there AND


25%·(20%)
first two holes are dry
2
20%)

lse

wet else first two holes are dry

y
75%
%

1.316%
0
1
2
3
4

Page 25
Data Tables

In Excel 2007, select Data, (Data Tools) What-If Analysis,


Data Table to get here.

multi-column table
1.316% 2 5
25.000% 0 1
6.250% 1 2
1.316% 2 5
0.266% 3 10
0.053% 4 17

horizontal table
0 1 2 3 4
25.000% 6.250% 1.316% 0.266% 0.053%

two-dimensional table
5% 20% 25% 80%
5.000% 20.000% 25.000% 80.000%
1.042% 4.762% 6.250% 44.444%
0.210% 0.990% 1.316% 13.793%
0.042% 0.200% 0.266% 3.101%
0.008% 0.040% 0.053% 0.636%

Page 26
Cash Management

A firm keeps its cash reserves in money-market certificates which


yield 9%, and makes periodic transfers to a non-interest-bearing
checking account. Transfers are practically instantaneous, and the
cost of a transfer is $300 (independent of the size of the transfer).
The firm writes about $5 million in checks per year.

(a) How large should each transfer be?

9% opportunity cost of capital


$5,000,000 annual demand for cash Solver setup
$32,250
$50,000 transfer amount answer: $182,574 1
100 transfers/year 1
$300 cost/transfer 100
$25,000 average inactive balance
$32,250 cost per year of managing cash

The bank which maintains the firm's accounts offers to let the firm
run a negative checking-account balance, but will charge 12% on
the average balance outstanding. Assume that the firm transfers
$400,000 whenever its balance drops to -$100,000.

(The total annual cost associated with this policy is $10,500.)

(b) When the balance is positive, how large, on average, is it? What
fraction of the year is the balance positive? How much interest is
lost, per year, on positive balances?

12% interest on negative balances `


$400,000 transfer amount answer: $365,148
-$100,000 transfer trigger balance -$273,861
75.00% fraction of year balance is positive Solver setup
$150,000 average balance when positive $14,250
$10,125 lost interest 2
1
(c) When the balance is negative, how large, on average, is it? 1
What fraction of the year is the balance negative? How much 100
interest does the firm pay, per year, on negative balances? How
much interest does it save, per year, by keeping cash in the
money-market account?

25.00% fraction of year balance is negative


-$50,000 average balance when negative
$375 net interest cost

(d) By how much should the firm overdraw its account before making
a transfer, and how large should each transfer be? (That is, what
is an optimal policy?)

12.50 transfers/year
$14,250 total cost per year
1
Selecting "Tools / Solver" brings up the main Solver dialog box
(in Excel 2007, Solver appears at the far right of the "Data" ribbon):

Selecting "Options" brings up:

If you select "Load Model," and then highlight one of the "boxes" in the
spreadsheet where I've previously "saved" (using the same "Options" screen)
a previous Solver setup, you can reload the saved setup and see it in detail
(after hitting "OK" a few times).

"Save Model" lets you save your own model for documentation purposes.
Solver (2)

The Irish Potato Famine


(a fanciful example)

A good Irish family likes to eat steak and potatoes for dinner
most nights. A pound of steak costs 6 shillings, and a pound of
potatoes costs only 2 shillings. The family has 72 shillings to
spend on food each week, and requires 20 pounds of food total
to keep everyone well-fed. Subject to these constraints, they'd
like to get as much nourishment as possible from tasty steak,
rather than from bland potatoes.
Solver setup
How should they plan their weekly purchases? 6
2
food 6 steak 6 price of steak 1
plan 14 potatoes 2 price of potatoes 1
1
maximize 6 (steak) 100

subject to 64 <= 72 (cash constraint)


20 >= 20 (quantity constraint)

We can let Solver plan out the family purchases. This time, select
Tools, Solver, set the "target cell" to C17 and tell Solver to
maximize it, and list C14, C15 as the changeable cells. Then add
two constraints: C19 <= E19, and C20 >= E20. And let's also
add constraints to keep C14 >= 0 and C15 >= 0.

Select "Solve", and we soon see that the best the family can do
is to buy 8 pounds of steak and 12 pounds of potatoes.

Imagine that the benevolent English government foresees a poor


potato crop this year, and decides to impose a 1 shilling / pound
tax on potatoes in order to lessen demand for them.

Raise the price of potatoes in cell F15 to 3 shillings / pound, and


resolve the problem. (Solver will remember the problem setup,
so all you need do is select Tools, Solver, Solve.)

Whoa! With the increase in price, demand for potatoes went UP!
(Potatoes are known in economics as a "Giffen good". Steak and Click here for the Wikipedia article on Giff
potatoes are substitute goods, and raising the price of the cheaper
good can increase demand for it.) For a practical modern example of a Giffe
imagine raising bus fares in a city: If peop
No wonder the Irish rebelled. traveling by taxi, but some are budget-con
currently use a mixture of taxi and bus tra
increase could increase the usage of the

Page 32
Solver (2)

Solver setup

for the Wikipedia article on Giffen goods.

ctical modern example of a Giffen good,


aising bus fares in a city: If people prefer
by taxi, but some are budget-constrained and
use a mixture of taxi and bus travel, the fare
could increase the usage of the city buses!

Page 33
Array formulas

Working with Array Formulas

The SUMPRODUCT function returns the x Pr( X = x )


sum of the products of matching terms 1 0.2
in two (or more) lists. For example, the 2 0.5
expected value of X, given the probability 5 0.3
distribution at the right, is

2.7 =SUMPRODUCT(F4:F6,G4:G6)

However, there's a slicker way to do the same calculation:

2.7 =SUM(F4:F6*G4:G6), entered as an array formula.

Array formulas are very powerful ... and potentially somewhat confusing.

An "array" has some number of rows, and some number of columns. In an


array formula, Excel finds the largest number of rows, R, in any array in the
formula, and the largest number of columns, C. It then expands any array
that is smaller than R-by-C in one of two ways. If R or C is 1, it copies the
single row or column to fill an entire R-by-C array. Otherwise, it adds extra
cells with the value NA (not available).

Then it does all the arithmetic on a cell-by-cell basis. And it


evaluates any formulas that take array inputs using the resulting
array as the input.

1 2 3
4 4 8 12
5 5 10 15
6 6 12 18 90

All nine cells inside the box are part of the same array,
defined by the single formula: {=C28:E28*B29:B31}

The formula was entered as an array formula. First, I highlighted


C29:E31. Then I typed =C28:E28*B29:B31, and entered the
formula by pressing Cntrl+Shift+Enter.

What Excel did was determine R = 3 (the number of rows in


B29:B31) and C = 3 (the number of columns in C28:E28).
It expanded B29:B31 into

4 4 4
5 5 5
6 6 6

and C28:E28 into

1 2 3

Page 34
Array formulas

1 2 3
1 2 3

Then it computed the products of matching cells, and put them


into the space allocated to the array formula.

The formula in F30 is =SUM(C28:E28*B29:B31), again entered


by pressing Ctrl+Shift+Enter.

Page 35
Matrix Multiplication

Consider the following two rectangular arrays ("matrices") of numbers, where


the first has as many columns as the second has rows.

2 1 0
1 3 5 0 3 1
2 4 3 4 5 2

The "product" of two such arrays is a third array, with as many rows as the
first and as many columns as the second. The (i-th row, j-th column)-entry of
the product is obtained by taking each number in the i-th row of the first,
multiplying times the corresponding number in the j-th column of the second,
and adding all the pairwise products.

Excel provides a function, =MMULT, to compute matrix products. Since the


result is itself an array, this function must be entered as an "array function"
in Excel.

In the example above, we expect a 2-rows-by-3-columns result, so we 1


highlight a 2-by-3 rectangle of cells, such as B26:D27. With those cells 2
highlighted, type the function: =MMULT(B7:D8,F6:H8), and then "enter" this
as an array formula by pressing Cntrl+Shift+Enter.

For example, 10 = 2 * 0 + 4 * 1 + 3 * 2 :
22 35 13
16 29 10 The 2nd-row, 3rd-column entry comes from "combining" the
2nd-row of the first matrix with the 3rd-column of the second matrix.

Note that the result cells are "live", i.e., changing any entry in either of the
first two matrices changes some of the cells in the product.

--------------------

Matrix multiplication provides a convenient way to summarize many types of computations.

Example: You make four different types of products from certain common raw materials.
(For example, the products could be different types of fuel requiring varying mixes of additives.)
To produce a unit of product A requires 1 unit of raw material 1, 2 units of raw material 2,
and 4 units of raw material 3. These requirements, and similar requirements for the other
products, are listed below, as is your production plan for the day:

raw raw raw production


material 1 material 2 material 3 plan
product A 1 2 4 1,000
product B 2 0 4 2,000
product C 4 2 2 1,500
product D 0 3 2 5,000

How many units of each raw material will be required to meet your production plan?
If you "lay down" the production plan:

product A product B product C product D


1,000 2,000 1,500 5,000

then your requirement for each material is just the product of the "plan" and the
"inputs" matrix:
raw raw raw
material 1 material 2 material 3
11,000 20,000 25,000 =MMULT(C54:F54,D45:F48)

Since this "laying-down" operation is sometimes needed to "prepare" matrices for


multiplication, Excel offers a useful transposition (i.e., "flipping") function: =TRANSPOSE .
Taking advantage of this function, we could have flipped the production plan on-the-fly:

raw raw raw


material 1 material 2 material 3
11,000 20,000 25,000 =MMULT(TRANSPOSE(H45:H48),D45:F48)

Example: (to be read after we discuss "random variables") You plan to spread
your capital across three investment opportunities, putting 30% into project A, 50% into
project B, and 20% into project C. Financial details on the projects are listed below:

project A project B project C


12% 16% 13% expected rate of return
30% 50% 20% proportion of capital invested

covariances of rates of return


project A project B project C
project A 0.00090 0.00042 0.00048
project B 0.00042 0.00490 0.00084
project C 0.00048 0.00084 0.00160

The variance in the rate of return on the portfolio, written algebraically, is

Var( 0.3*RORA + 0.5*RORB + 0.2*RORC ) =

(0.3)2*Var(RORA) + (0.5)2*Var(RORB) + (0.2)2*Var(RORC)


+ 2*(0.3)*(0.5)*Cov(RORA,RORB)
+ 2*(0.3)*(0.2)*Cov(RORA,RORC)
+ 2*(0.5)*(0.2)*Cov(RORB,RORC)

It would take a bit of work to pull this all together manually. But a double
matrix multiplication makes it simple:

0.001722 variance of rate of return on portfolio


=MMULT(MMULT(C77:E77,C81:E83),TRANSPOSE(C77:E77))
(Just once in your life, you might want to do the matrix multiplications manually in order
to verify for yourself that this really works.)

14.20% expected rate of return on portfolio


4.15% standard deviation of rate of return on portfolio

Well, okay. Maybe the matrix formulation doesn't look all that much simpler. But if
we were spreading our capital across ten different projects, we'd have 55 separate
terms to compute "algebraically." Using the matrix formulation, all the pieces of the
calculations are pulled together automatically!
3 5
4 3

2 1 0
0 3 1
4 5 2

"combining" the
mn of the second matrix.
H48),D45:F48)

You might also like