Professional Documents
Culture Documents
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
Spreadsheet tools
Simulation skills
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)
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 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)
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
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
What is E[X2] ?
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)
#VALUE!
criteria. Such criteria (count people with the same birthday)
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
1/1/2008 #VALUE!
12/31/2008 #VALUE!
e, criterion, sum-range)
both entered by
typing Ctrl+Shift+Enter
UE evaluates to 1, and
Three Useful "Counting" Formulas
FACT(n) = n! = 1·2·3·...·n .
Note:
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
=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.
0.134524 =RAND(). Press [F9] a few times, and watch this change.
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!
$16,056.25 #VALUE!
$78,850.00 #VALUE!
28% #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
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!
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)
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
=POISSON(x,mean,cumulative)
0.122138 #VALUE!
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
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.
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
That is,
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]
Page 20
Statistical Functions
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
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?
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.
Page 23
Data Tables
I clicked in "Column input cell", then clicked cell B20 and "OK."
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.
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
lse
y
75%
%
1.316%
0
1
2
3
4
Page 25
Data Tables
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
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.
(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?
(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):
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)
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
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.
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
Page 33
Array formulas
2.7 =SUMPRODUCT(F4:F6,G4:G6)
Array formulas are very powerful ... and potentially somewhat confusing.
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}
4 4 4
5 5 5
6 6 6
1 2 3
Page 34
Array formulas
1 2 3
1 2 3
Page 35
Matrix Multiplication
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.
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.
--------------------
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:
How many units of each raw material will be required to meet your production plan?
If you "lay down" the production plan:
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)
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:
It would take a bit of work to pull this all together manually. But a double
matrix multiplication makes it simple:
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)