a core course on modeling
DESCRIPTION
A Core Course on Modeling. Week 4-The Function of Functions. Contents . What is a Formal Model? A Practical Route to Formal Models Example 1: The Detergent Problem Example 2: The Chimney Sweepers Problem Example 3: The Peanut Butter Problem The relation wizard - PowerPoint PPT PresentationTRANSCRIPT
1
A Core Course on Modeling
Contents • What is a Formal Model?
• A Practical Route to Formal Models
• Example 1: The Detergent Problem
• Example 2: The Chimney Sweepers Problem
• Example 3: The Peanut Butter Problem
•The relation wizard
•The function selector• Summary
• References to lecture notes + book
• References to quiz-questions and homework assignments (lecture notes)
Week 4-The Function of Functions
2
A Core Course on Modeling
What is a Formal Model? What is the meaning of + ?
resistors: Rtot = R1 + R2
springs: Ctot = 1/(1/C1+1/C2)
resistors: Rtot = 1/(1/R1 + 1/R2)
springs: Ctot = C1 + C2
the intuition of ‘addition’, ‘accumulation’:
Week 4-The Function of Functions
3
A Core Course on Modeling
What is a Formal Model? What is the meaning of + ?
Week 4-The Function of Functions
Conclusion: there is always a need for interpretation going from relations in ‘real world’ to mathematical relations
There is no simple, generic way to infer mathematical relations from relations in real world
We need a (heuristic) process to do so.
the intuition of ‘addition’, ‘accumulation’:
4
A Core Course on Modeling
A Practical Route to Formal Models Heuristics to arrive at formal expressions:
• meaningful names
• chain of dependencies
• todo-list
• dimensional analysis
• wisdom of the crowds
• two models is better than one model
• when is a model good enough?
• Baron von Münchhausen
In a conceptual model, properties are always part of a concept (‘myCar.wheel.diameter’). In a formal model, properties may be ‘just’ quantities (‘myCarWheelDiameter) with names that may be meaningfully abbreviated (‘mCWhD’).
General scheme: start with the quantitiy needed for your purpose, and try to express this in other quantities
•in the simplest possible form
•with as few as possible assumptions
•such that the quantity is written as function of the other quantities
•continue with the arguments of the function
Everytime when introducing a new quantity, add it to the todo list. When a quantity is expressed into in something known (= a value or another expression), take it off the todo list. When the todo list is empty, model’s first version is ready.
When seeking a mathematical expression,
•if possible, use dimensional considerations to find needed expression …
•… but at least verify expression with dimensional analysis
•… even if this may require inventing units and dimensions.
Often values need guessing. If you can involve a number of people, let them guess independently. This gives (a) a more accurate estimate if there are no systematic errors and (b) an idea of the variation.
Otherwise: try to relate the unknown values to values you (and your friends) may know.
Sometimes, there are two or more routes to (part) of your model. Implement them all, and compare the results. The spread in results is a clue to the reliability of the achievable outcome.
A model is never complete and fully accurate. But, given its purpose, it can be complete and accurate enough. (See chapter 6.) Regularly check if your purpose is met.
Once you have your first version running, you can:
•use it to find out which of the uncertainties of your inputs are the most dominant try to get these more accurate if necessary
•find out which modifications could be worthwhile
Week 4-The Function of Functions
5
A Core Course on Modeling
The Detergent Problem
“What is the total amount of detergent
annually dumped in the
Environment in the Netherlnds?
Week 4-The Function of Functions
6
A Core Course on Modeling
amAnDetDmp =
f(nrAnWshs , detPWsh)
relations dimensions assumptions todo[kg / year] =
F([wash / year] , [kg / wash])
amAnDetDmp
nrAnWshs
detPWsh
Det:detergent; An: annual; Wsh: wash; Fam: family; P: people; am: amount; Dmp: dump
The Detergent Problem
Week 4-The Function of Functions
7
A Core Course on Modeling
amAnDetDmp =
nrAnWshs * detPWsh
relations dimensions assumptions todo[kg / year] =
[wash / year] * [kg / wash]amAnDetDmp
nrAnWshs
detPWsh
Det:detergent; An: annual; Wsh: wash; Fam: family; P: people; am: amount; Dmp: dump
The Detergent Problem
Week 4-The Function of Functions
8
A Core Course on Modeling
amAnDetDmp =
nrAnWshs * detPWsh
relations dimensions assumptions todo[kg / year] =
[wash / year] * [kg / wash]
Washing laundry is the only
way detergent gets into the
environment
amAnDetDmp
nrAnWshs
detPWsh
nrAnWshsPFam
nrFamIH
nrPIH
nrPPFam
nrAnWshs =
nrAnWshsPFam * nrFamIH
[wash / year] =
[wash / (fam *year)] * [fam]
No institutional laundry washing, only families
nrFamIH =
nrPIH / nrPPFam
[fam] =
[people] / [people / fam]
Everybody belongs to exactly one family: families are disjoint
nrPIH = 17 0.5 million [people] common knowledge
nrPPFam = 2.2 0.2 [people/fam] public domain
nrAnWshsPFam = 100 20 [wash / year] wisdom of the crowds
Det:detergent; An: annual; Wsh: wash; Fam: family; P: people; am: amount; Dmp: dump
detPWsh = 0.17 0.03 [kg / wash] wisdom of the crowds
todo list is empty model is ready
The Detergent Problem
Week 4-The Function of Functions
9
A Core Course on Modeling
todo
amAnDetDmp
nrAnWshs
detPWsh
nrAnWshsPFam
nrFamIH
nrPIH
nrPPFam
The Detergent Problem
Week 4-The Function of Functions
amAnDetDmp
nrPPFamnrPIH
nrFamIH
nrAnWshsPFam
detPWshnrAnWshs *
/
*
10
A Core Course on Modeling
todo
amAnDetDmp
nrAnWshs
detPWsh
nrAnWshsPFam
nrFamIH
nrPIH
nrPPFam
The Detergent Problem
Week 4-The Function of Functions
amAnDetDmp
nrPPFamnrPIH
nrFamIH
nrAnWshsPFam
detPWshnrAnWshs *
/
*
170.5 million2.20.2
7.72 … million
0.170.03
1.31… million
772…million
10020
11
A Core Course on Modeling
This type of model is a ‘thumbnail calculation’:
• OK for quick order of magnitude estimations
• Uses straightforward substitutions, only based on dimension analysis
• Work with intervals to get an impression of the variation of the answers (143 67 M; correct value according to various sites such as http://wiki.watmooi.nl/pages/Wassen_en_onderhoud is 150 M kg)
• Purpose: pub quizzes, trivial pursuit, …
a.k.a. ‘sledgehammer estimation’
The Detergent Problem
Week 4-The Function of Functions
12
A Core Course on Modeling
About accuracy
model: outcome = function of inputs
y=f(x1,x2,…)
y=f/x1 x1 + f/x2 x2 + …
So:
|y|=|f/x1| |x1| + |f/x2| |x2| + …
This is a very pessimistic upperbound: all quantities need to conspire to give worst case deviation.
In chapter 6, we will get a more realistic estimate.
The Detergent Problem
Week 4-The Function of Functions
13
A Core Course on Modeling
The Chimney Sweepers Problem
“How many chimney sweepers
work in Amsterdam?”
Week 4-The Function of Functions
14
A Core Course on Modeling
nrChSwIA =
nrChIA * nrSwPCh
relations dimensions assumptions todo
[Sw / A] =
[Ch / A] * [SW / Ch]
Amsterdam ch.-sweepers
sweep Amsterdam
chimneys only
nrChSwIA
nrChIA
nrSwPCh
nrChPFam
nrFamIA
nrPIA
nrPPFam
nrChIA =
nrChPFam * nrFamIA
[Ch / A] =
[Ch / Fam] * [Fam / A]
ch.-sweepers sweep only chimneys on family houses
nrFamIA =
nrPIA / nrPPFam
[Fam / A] =
[P / A] / [P / Fam]
nrPPFam is the same everywhere (does not depend on ‘Amsterdam’)
nrPIA = 790000 [P] common knowledge
nrPPFam = 2.2 0.2 [P/Fam] public domain
nrChPFam (= 1/nrFamPCh) =0.10.02 [Ch/Fam]
wisdom of the crowds
Sw=sweeper; Ch=chimney;A=Amsterdam;Fam=Family;P=people;Se=Service;
The Chimney Sweepers Problem
Week 4-The Function of Functions
15
A Core Course on Modeling
nrSwPCh =
nrSwPSe * nrSePCh
relations dimensions assumptions todo
[Sw / Ch] =
[Sw*year/Se] * [Se/(Ch*year)]
Introduce time to associate sweeper’s ca-pacity to chimney’s need
nrChSwIA
nrChIA
nrSwPCh
nrChPFam
nrFamIA
nrPIA
nrPPFam
nrSwPSe
nrSePCh
timeP1Se
timeP1Sw
nrSwPSe =
timeP1Se / timeP1Sw
[Sw * year / Se] =
[hour / Se] / [hour / (Sw*year)]
assume average times (i.e., no season influences
etc.)
timeP1Sw = 1200100 hour / Sw * year)
Sw=sweeper; Ch=chimney;A=Amsterdam;Fam=Family;P=people;Se=Service;
timeP1Se = 20.25 hour / Se wisdom of the crowds
work year = 1600 hours
nrSePCh = 1 Se /( Ch * year) insurance requirement
todo list is empty model is ready
but what does it mean ? NOTHING, since we formulated no purpose
The Chimney Sweepers Problem Notice: two different units, both with dimension time. To verify that units are consistent, substitute back into expressions for nrSwPSe and nrSwPCh: check that all units multiply and divide to produce the correct final result.
In this case: nrSwPCh=timeP1Se * nrSePCh / timeP1Sw has unit ‘sweeper / chimney’ – which is correct.
Week 4-The Function of Functions
To find an expression for nrSwPCh, ask: ‘what links the nr of sweepers to the nr chimneys?’. Answer: sweepers service chimneys. ‘How many services’ (1) relates to the capacity (=available resource) of a sweeper, and (2) to the need of a chimney (=needed resource). Here, ‘resource’=time. The capacity of a sweeper is expressed in the time he works ([Sw*year]); The ‘need’ of a chimney is therefore expressed ([Ch*year]).
16
A Core Course on Modeling
but what does it mean ? NOTHING, since we formulated no purpose
What purposes could we think of:
are there at least 300 Chimney Sweepers so that we can begin a professional journal?
so: we only need to know if NrChSwIA > 300
are there less than 50 Chimney Sweepers so that we can have next year’s ChSw convention meeting in the Restaurant ‘the Swinging Sweeper?’
so: we only need to know if NrChSwIA <50
are there about as many Chimney Sweepers as there are Sewer Cleaners so that we can form efficient ‘Chimney and Sewage Control and Service Units’?
so: we only need to know if NrChSwIA is between 50 and 60…
… each purpose poses different challenges / allows different approximations in our model.
The Chimney Sweepers Problem
Week 4-The Function of Functions
17
A Core Course on Modeling
To assess credibility of a model:
•confront with actual measurements
•confront with outcome of a second, independent model
• how much soot and ashes are disposed of by the municipal Ash & Soot Depot?
• how often do you see a chimney sweeper at work (wisdom of the crowds)?
• how much money do people in A. spend annually in cleaning their chimneys?
check out a model for the later case:
(notice: this model is not completely independent from the previous; it uses some common quantities)
The Chimney Sweepers Problem doing experiments: beyond the scope
of modeling
Week 4-The Function of Functions
18
A Core Course on Modeling
Thusfar, all mathematical relations were obtained via dimension analysis.
Dimensions are more generic than just SI dimensions/units.
Dimensional analysis often works for models of a particular form:
y = x1n1 * x2
n2 * x3n3 … = i xi
ni,
where (integer) ni can be both larger and smaller than 0.
How to go about when other forms are needed?
The Chimney Sweepers Problem
Week 4-The Function of Functions
19
A Core Course on Modeling
The Peanut Butter Problem
“How to get rich
by selling a new brand
of
peanut butter?”
PB
Week 4-The Function of Functions
20
A Core Course on Modeling
income =
pricePerItem * nrSoldItems
relations dimensions assumptions todo
[Euro / year] =
[Euro/myPB] * [myPB/year]
no discount with larger quantities per purchase
profit
income
expenses
pricePerItem
nrSoldItems
nrSoldTotal
marketSharenrSoldItems =
nrSoldTotal * marketShare
[myPB / year] =
[allPB / year] * [myPB/allPB]
my PB will not increase the total market
pricePerItem = …
nrSoldTotal = … [allPB/year] from a neutral marketing bureau
marketShare = …
problems:
• I have a choice for pricePerItem
• marketShare depends on pricePerItem
The Peanut Butter Problem
Week 4-The Function of Functions
profit = income - expenses [Euro / year] = [Euro/year] no taxes, no inflation
21
A Core Course on Modeling
problems:
• I have a choice for pricePerItem
• marketShare depends on pricePerItem
Approach 1: glass box (glass jar …;-):
pricePerItem
mar
ketS
hare
0
1
??
The Peanut Butter Problem
Week 4-The Function of Functions
22
A Core Course on Modeling
problems:
• I have a choice for pricePerItem
• marketShare depends on pricePerItem
Approach 1: glass box (glass jar …;-):
pricePerItem
mar
ketS
hare
0
1
What mechanism determines marketShare(pricePerItem)?• monotonically decreasing• between 0 and 1• asymptote: marketShare0 if pricePerItem • asymptote: marketShare1 if pricePerItem - • what sort of mathematical dependency ???
The Peanut Butter Problem
If something gets more expensive, the chance people will buy it decreases
A market share cannot be <0; it could be >1 but only if it creates additional request
If something gets sufficiently expensive, nobody will buy itIf something gets sufficiently cheap, every potentially interested customer will buy (or get!) it
It would need a glass box model of customers’ brains to derive this dependency from first principles
Week 4-The Function of Functions
23
A Core Course on Modeling
problems:
• I have a choice for pricePerItem
• marketShare depends on pricePerItem
Approach 1: glass box (glass jar …;-):
pricePerItem
mar
ketS
hare
0
1
cheapestcompetitor
most expensivecompetitor
1st guess: straight lines
• advantage: simple
• disadvantage: not smooth
• uncertain: does this represent the actual behavior?
The Peanut Butter Problem
Week 4-The Function of Functions
24
A Core Course on Modeling
problems:
• I have a choice for pricePerItem
• marketShare depends on pricePerItem
Approach 1: glass box (glass jar …;-):
pricePerItem
mar
ketS
hare
0
1
cheapestcompetitor
most expensivecompetitor
2nd, 3rd guess: arctan, logistic, …?
• advantage: smooth
• disadvantage: more parameters?
• what values for the parameters?
• uncertain if this follows the actual behaviour
The Peanut Butter Problem Depending on what you are going to DO with the math (e.g., optimisation), smoothness can be important
Week 4-The Function of Functions
25
A Core Course on Modeling
problems:
• I have a choice for pricePerItem
• marketShare depends on pricePerItem
Approach 1: glass box (glass jar …;-):
pricePerItem
mar
ketS
hare
0
1
cheapestcompetitor
most expensivecompetitor
The Peanut Butter Problem
Week 4-The Function of Functions
26
A Core Course on Modeling
problems:
• I have a choice for pricePerItem
• marketShare depends on pricePerItem
Approach 2: black box: use panel of test subjects; ask them if they would buy your PB for price X
pricePerItem
mar
ketS
hare
0
1 do a smooth curve fit (e.g., splines) that satisfies 0 marketShare 1
The Peanut Butter Problem
Week 4-The Function of Functions
27
A Core Course on Modeling
problems:
• I have a choice for pricePerItem
• marketShare depends on pricePerItem
Approach 2: black box: use panel of test subjects; ask them if they would buy your PB for price X
pricePerItem
mar
ketS
hare
0
1 do a smooth curve fit (e.g., splines) that satisfies 0 marketShare 1
but, anyway:
let us assume we have some function:
then the model predicts the income
as function of the pricePerItem.
The Peanut Butter Problem
Week 4-The Function of Functions
28
A Core Course on Modeling
Revisit the peanut butter example:
income=pricePerItem * nrSoldItems
nrSoldItems=nrSoldTotal * marketShare
marketShare=f(pricePerItem)
for convenience, introduce abbreviations:
The Peanut Butter Problem
Week 4-The Function of Functions
29
A Core Course on Modeling
Revisit the peanut butter example:
inc =pPI * nSI (inc=income; pPI=pricePerItem; nSI=nrSoldItems)
nSI = nST * mSh (nST=nrSoldTotal; mSh=marketShare)
mSh=f(pPI)
So: inc = pPI * nST * mSh(pPI)
This is naive: first, realize that nST = i nSTi, i ranges over customers.
So: inc = pPI * mSh(pPI) * i nST(i)
Improved model: inc = pPI * i nST(i) * mSh(pPI, i)
The Peanut Butter Problem This is irrelevant if all customers would buy equal amounts of peanutbutter. But: there are mega-consumers and mini-consumers !
Realize that the decision to choose MY peanutbutter is taken by a customer. Suppose that the majority of mega customers would decide against my peanutbutter – then the original model with mSh(pPI) instead of mSh(pPI,i) would give an overestimate misleading.
So: think about which arguments a function should depend on!
Week 4-The Function of Functions
30
A Core Course on Modeling
To go from conceptual model to formal model:
while your purpose is not satisfied:
•start with quantity you need for the purpose•put this on the to-do list•while the todo list is not empty:
•take a quantity from the todo list•think: what does it depend on?
•if depends on nothing substitute constant value (perhaps with uncertainty bounds)
•else give an expression for it•if possible, use dimensional analysis•propose suitable mathematical expression•think about assumptions•in any case, verify dimensions
•add newly introduced quantities to the todo list
•todo list is empty: evaluate your model•check if purpose is satisfied; if not, refine your model
• ready
The Peanut Butter Problem
Week 4-The Function of Functions
31
A Core Course on Modeling
To go from conceptual model to formal model:
while your purpose is not satisfied:
•start with quantity you need for the purpose•put this on the to-do list•while the todo list is not empty:
•take a quantity from the todo list•think: what does it depend on?
•if depends on nothing substitute constant value (perhaps with uncertainty bounds)
•else give an expression for it•if possible, use dimensional analysis•propose suitable mathematical expression•think about assumptions•in any case, verify dimensions
•add newly introduced quantities to the todo list
•todo list is empty: evaluate your model•check if purpose is satisfied; if not, refine your model
• ready
splinearctan
asym
pto
t
efunction selectorfunction selectorfunction selectorfunction selector
relation wizardrelation wizardrelation wizardrelation wizard
logistic
function
optim
isat
ion
The Peanut Butter Problem
Week 4-The Function of Functions
32
A Core Course on Modeling
• Conceptual model formal model : not in a formally provable correct way;
• Appropriate naming
• Structure
• Chain of dependencies: the formal model as a directed acyclic graph;
•What mechanism?
•What quantities drive this mechanism?
•What is the qualitative behavior of the mechanism?
•What is the mathematical expression to describe this mechanism?
• To-do-list : all intermediate quantities are found and elaborated in turn;
• Formation of mathematical expressions:
•dimensional analysis mathematical expressions, e.g in the case of proportionality
•the Relation Wizard can help finding appropriate fragments of mathematics;
•the Function Selector can help finding an appropriate expression for a desired behavior;
•wisdom of the crowds can help improve the accuracy of guessed values;
Summary
Week 4-The Function of Functions