Stony Brook MAT 122 Fall 2017
Lecture 06: Mathematical Modeling
September 11, 2017

Start   She seems to be fine.
Talked to my mother over the weekend. She says I'm fine don't worry about me.
If I'm dead the police will call you.
Gotta admire that.
She doesn't scare easily. She said she survived world war two.
She survived the missiles. She'll survive this.
That's the right attitude. Hi.
You have a homework question?
Yeah how many attempts do we have?
I think I either said 5 or unlimited.
0:31It's five per question.
So the first homework assignment should be pretty simple I really just want you guys to sort of hang of mymathlab.
Wow that's just a really loud microphone.
Which is good because sometimes they don't work at all.
So we're getting the video page organized. I'll have that up some time later today.
It's not Echo. It's just our actual math department video page.
It's really just raw footage of me standing here doing my thing.
Okay? Or my thang. Depending on your point of view.
1:04They're not exciting but we are sort of running ahead of the syllabus which makes me very happy because it gives me more time to review later and of course it means we'll have more opportunities to end early. So there you go.
Okay so we'll talk a little more about mathy stuff and mathematical modeling.
1:33Well speak of modeling.
So we got the weather thing going on so why is it the weather is so hard tomorrow?
To predict.
I mean these guys a terrible. They're not embarrassed that they're terrible I mean they're terrible.
Right? I mean first of all it's incredibly difficult when a hurricane is say in Cuba to figure out if it'a gonna hit the east coast of Florida or the west coast of Florida because it's actually a very narrow bend.
So if you were watching the weather forecasts
2:00Friday they were still saying it was gonna hit the east coast. It wasn't until it got really close that they can predict which way it's gonna go because you know it's a very small deviation you have to think of it as a comb.
Right? It's like when Sandy came here we thought that Sandy would hit Manhattan dead on and it turned out it sort of hit about Mid Nassau county. That's a very small difference.
Let's say 15 miles in a thousand mile wide storm that's coming at you from hundreds of miles away.
2:30So in that regard I can give the weather people a lot of credit.
That they at least get close.
Okay. It's very hard to get it exactly right but Jose is churning up there down in the Atlantic near the Caribbean.
And we don't know if it's gonna come here a week from now. Is it gonna go out father out to sea?
Or is it gonna head west? And the prediction is next weekend will be Jose's weekend to make a mess out of everything.
I don't know if we have anybody here named Jose but it's your fault.
3:02But why is it so hard to get the weather right?
Because let's take physics okay? You throw a ball in the air You catch the ball. You can very accurately figure out how high that ball's gonna go and where it's going to land.
You know a football quarterback can throw the ball 50 yards while he's being chased by 3 huge people and get it in some guys hands while he's running so clearly you can, and by the way if it were a drone it would be precise.
3:30So clearly there's ways to get these things incredibly accurate you know we can send astronauts to the moon and hit the moon.
So why is it so hard to predict something like the weather?
Anybody have any ideas? Because it's actually relevant to business.
There's a lot of variables so go ahead.
Well, unpredictable by definition is- okay so what are some of the variables in predicting weather?
4:00What factors of weather would we need?
So you're hired to make the model. Because this can be relevant to a business model it's the same kinda thing.
So you want to make a model you want to model the weather. What inputs are you gonna need?
Okay so you need like wind.
Okay so you need wind. What else do you need?
Temperature.
Location. Right.
Any others? You don't need as many as you think.
Parametric pressure. Which is related to wind.
4:31And you probably need humidity to know how much moisture is in the air.
That's about it. Now might you need some time data.
Okay you might need to know say where something was 3 days ago and 5 days ago, but as we've seen 5 days is already very far out.
Say if you think of this as a comb and you start at the base of the comb 5 days later you could go very far out. It's very hard to predict where in that comb you're gonna be.
5:0112 hours is not so bad.
How about historical data? Is it good to know that last year the temperature was such and such.
That's probably a lot less value but some value because as we know there's sort of a hurricane season although hurricane season is sort of half the year so it's not really a very small window.
But it is sort of useful to know sort of previous times when you had certain conditions how things responded versus this time when you have certain conditions.
5:30The other thing is, because this is a calculus class, the variables. The unpredictability.
These aren't x and y where x and y are single numbers.
These are x and y where x and y are things that are changing.
So what calculus is about, calculus is about how things change.
Remember I told you that the first day.
So the variables will be represented by derivatives.
Often with multiple variables inside so the equations the things that you're working with aren't just x, y, and z but the way x is changing, y is changing, z is changing.
6:04These are incredibly complex equations. They're so complex that a bunch of super computers turn them out and they disagree with each other and you don't know until afterwards whether you got it right or not.
So now in business you're going to have the same kind of problem.
It isn't physics. It isn't where we know what gravity is within several decimal places.
It's business. So somebody says well we want to model the stock market.
6:31Who cares what the stock market was last year? Although the last time that the S&P index was at this number it responded in a certain way. It may help you figure out whether the S&P index will respond this way again.
You would need- say you wanted to figure out he way stocks were behaving.
You would need price data, you would need to know certain factors of the economy, you might need to know interest rates, you might wanna know uh, what would be factors of the economy?
Consumer spending. Variables like energy. What is the cost of oil.
7:03Is that an input? Maybe the exchange rates. What the dollar is versus euro versus the pound versus the last time you did the model.
Again, in fact in the stock market there can be many more inputs.
And it's very difficult, obviously it's very difficult to model the financial market.
If it were easy people would do it and they would get very rich.
The guy who paid for this building Jim Simons is probably a master at the moment of figuring out how the markets gonna do.
7:32He works in microseconds and milliseconds.
They can- trades that they execute that literally last for a millionth of a second.
Buy and sell them a millionth of a second later.
Which is obscene if you think about it But they devise ways to do this many many times with large amounts of money and therefore generate billions of dollars.
I don't know if you know much about Jim Simons but Jim Simons was chairman of math here at Stony Brook in the 70's and then started this hedge fund and it's been the most successful what's called
8:04quantitative hedge fund in the world. Based right here in Setauket. And he's worth at least a few billion dollars. It's a big number.
He's been very good to Stony Brook. Paid for the Simons Center. Pays for all sorts of stuff donates lots of money.
And he does that kind of mathematical modeling and he will tell you that the weather is hard.
So when you're doing- you're out in the business world and you might be asked to do a model of sales data.
8:30So now then you might only need a couple of inputs.
What do we sell of each type of thing over a particular period of time?
When you take BUS 220 it's the first time you really get to do a lot of that modeling.
We're just gonna sort of brush the surface of it in this class thank goodness.
But you'd say if we were modeling say sales of your new app you kinda want to know how the last app sold. Who bought it.
What did they pay for it? How many downloads per hour? Per month?
9:02Per day per week per month?
And with that you might be able to get a reasonable model of how your app will sell this time around.
So mathematical modeling, we're gonna do a little bit of it right now is all about developing that and if that sounds scary, it's not.
Believe it or not you could do a lot of this stuff very simply.
The first thing you want to try to do remember we talked about the different types of curves?
Is you wanna kind of try to figure out what kind of
9:31model do I want to look for? Linear growth, exponential growth, quadratic growth... ect. so let's take one of their examples.
And you do a lot of these with statistical modeling.
Here we go this is a good example.
10:07Okay so suppose we're given the following data.
Okay so we have years since 2005 so in 2005 is the year 0.
10:32And we've got number of households with high speed internet.
Okay we've got 25.4
11:0328.9 35.7 39.3 41.8 44.4 47.3 and 50.3. I'll give you a minute to copy all that down.
12:05This section is R6 this is the last of the stuff you're supposed to know before the class starts.
But we don't treat it that way we figure we'll teach it to you anyway.
Okay so now let's graph this.
Maybe that'll help us figure out what model we should use so 1 2 3 4 5 6 7
12:34And then you put a little squiggle in the graph to sort of indicate that you're not starting at zero the other way, it's totally unnecessary.
Let's do 25, 30, 35, 40, 45, 50, 55.
13:00Okay so let's see in year 0 we had 25.4 so that's right around 25.
And then we had 28.9.
35 and then 40 42 44 47 and then 50. So that kinda looks like a line.
13:34Although as I look at the spreads, notice this goes up by 3.5 This goes up by 6.8.
3.6 2.5. That's the difference between the one number and the next right?
2.6
14:012.9 and 3.
So we've got one big year and then it seems to be kinda to stay 3ish.
Per year. 3 million additional families per year.
Now of course it can't go in a straight line forever right?
Because at some point you run out of families.
You can use a linear model to approximate. You might be doing this.
14:30Long term. Because you're going to hit a certain number, you're gonna get all the families and then that's it you're not gonna get any more.
Unless they start dropping.
But we also could do it with a linear model.
And a linear models probably easier to make because we all know how to do lines.
y = mx+b stuff right?
So I would probably say at least if we're projecting out the boss comes to you and says I want to project how many I'm gonna sell in the next 3 years.
15:00How many families can I add? Well for 3 more years I would probably stick with a linear model.
In fact you can say yes it will probably go up 3ish per year.
So you would use linear regression but we could just do some slopes we could say from any one year so we can average these slopes.
That's a six if you can't tell from my perfect handwriting.
Could you guess what grade I got in penmanship when I was young?
15:36The teacher gave me an F, but probably that's only because you can't give lower than F.
And how many have we got?
7.
16:00I get 24.9 Well let's see.
7 times 3.5 is 24.5 so 3.5 sorry it's about 3.6?
Sure. Doesn't really matter.
Okay and if you were doing this model you might say well the 6.8 is a big year.
Other than that year it's pretty ? so you might throw it out of your calculations.
16:35If you wanted to find the slope of this line I might redo this removing this outlier.
And instead doing 18.1 divided by 6, which is we'll call it roughly 3.
3.6 looks a little big right?
We only had one year where we got to 3.6 generally it seems to be under that.
17:01So as I said I might throw out the outlier. You can throw out one from the other end just to be fair.
This gives you a good idea and then you say okay what's my starting number? My y-intercept is 25.4.
So you can say that the number of households we're gonna have is about 25.4 + 3t, where t is the number of years post 2005.
17:38And then let's test this. So this is our guess for our model.
And now you try some numbers. You say well when it's 0 you get 25.4 When it's 1 you get 28.4 That's not bad.
When it's 2 you get 31 so you're kinda off there but at 3 you're at 34.4 and at 4 you're at 37.4
18:00so we're getting close.
Then you might tweak the model a little bit.
But the idea of the mathematical modeling is now, and by the way they're paying you.
You wanna justify your salary so you sit there all day tweaking the numbers trying to make it look real pretty and all that.
You say at year seven it's only 46-ish. It's a little off so you might wanna make that a 3.1 instead of the 3 but 3.6 would probably get you too big.
And that's one way you can do mathematical modeling it's very simple.
18:30Another is you could do linear regression which is statistics class.
So you can have a computer model which tries to minimize the errors.
So it looks at each error versus your line, adds them all up and finds the best line to minimize this.
But that's one idea how to do a mathematical model.
And let's see. They came up with 2.92.
But they started at 29.86.
19:01So close enough.
Okay a different type of model.
How about study time.
19:32versus test scores. You know studying gets in the way of drinking but it's something you have to do.
So let's say 5, 6, 7, 8, 9, and 10.
20:04Oh it looks like the more you study the better you'll do.
Right it kinda looks that way? Of course you hope there's a curve.
Say I only put in 5 hours I'm hanging out with my friends.
See we can make a fast linear model of that.
Now wait I've got 6 numbers 6 numbers okay yeah.
So why don't you take a couple of minutes and see if you can make a quick linear model
22:16Why would linear not be a good model long term?
Because you get to a point where you have more than 100.
Which is awesome and mom is really happy but it's not realistic.
But you might be okay with the 4-12 hour study window.
22:37You're not sure.
But what other kind of model would you get for studying?
I mean I would say that a curved model where you get to a horizontal asymptote makes sense because at some point you've sort of studied everything.
And the next hour of studying would get you almost nothing.
Other than tired.
And in fact too much studying you might start to come down again.
23:00But for the purposes of this you might use a linear model.
So we find the slopes.
So you'd say well these two difference in y's these two difference in x's.
You can do it by a couple of different approaches.
But probably the easiest approach is you say here I've got slopes of 9, 3, 2, 3, and 3, so that 9 is an outlier.
And you could divide that by 5.
23:30And that comes out exactly 4.
Or you could throw this out and say and that gives you 11/4 which is 11/4.
So you could say the slope is somewhere in there.
And you need a starting number.
So we need the equation of the line.
So let's see what's the equation of a line?
24:00y-y1= m (x-x1) So who used 4 as their slope?
Anybody? You guys all threw out the 9 and used 11/4 as your slope?
How many of you are just waiting for me?
There's a lot of that?
Okay. It's not hard to raise your hands at some point in the business word.
Okay so did you see what I did?
I took the difference between each successive score
24:31because as I said one more hour and then I said how much does that add in time?
Well going from 5 to 6 hours adds a lot and then from 6 to 7, 7 to 8 was pretty consistently 3-ish.
I averaged them. So I could tell you the average is either around 4 or if I throw out that first 9 hour increase I only get 11/4.
Ah why did I put it over 5 instead of 6?
25:00Because I'm counting the number of slopes.
Right? So slope, slope, slope, slope, slope.
That's a good question, okay?
So you guys all get to this step?
More or less?
Happy faces. Okay so you know you can go somewhere between the two. Let's see what the models look like.
So we'll try it both ways.
So you pick any point so how about 10, 91? 10 is kinda fun to work with.
25:35So we'll say x1, y1 so this is gonna be hours and this is gonna be score.
And that's 10, 91.
So you say y - 91= 4 ( x - 10 ) y - 91 = 4x - 40
26:01y = 4x + 51 So this model would say if you do nothing you'll get a 51 on the test.
Which by the way if that's a B I would do nothing for a B.
5 extra hours of partying.
You know that's why you have to get an F okay?
You have to say a 51 is an F because you don't want to say to kids well you can do nothing and still pass.
26:30Of course you guys all want that I understand but the pedagogical idea is you don't want to reward zero studying.
And then we could also instead of doing 4 we can say well let's say it's 11/4 so y, which is an annoying number to work with but So that comes out y = 11x /4 + 254/4.
27:09Which is 58.5.
27:30That's not correct. Ignore what I just said.
63.5 there you go.
Alright much better.
That says now 11/4 is 2.75.
put maybe 3-ish you might wanna make the model easier remember of course we'll be using calculator or computer so you really don't care if you have messy numbers.
And then how would we test the quality of our model?
28:01Well you plug in 5, 6, 7, 8, 9, 10 into both of these models and see which one gives you a better result.
So this one says after 5 hours you should get a 71 that's perfect.
And this says after 5 hours you'd get 309/4 which is 74.75.
28:33So it's a little higher but then you check all the different values so a 10 this says you get a 91 and that's looking pretty good. And a 10 this is 91.
Okay so they're both pretty good attempts so you try 3 or 4 of those and see what works.
Okay you don't have to do it in your head obviously you'll have a calculator. I'm probably making some calculation errors.
29:00So were you guys able to do this kind of a model?
Is this hard? It's not hard. As I said of course the linear model is not necessarily realistic.
You might wanna try other types of models.
So you could have something like a quadratic model.
So they've done studies oh this one is entertaining.
Average number of hours of sleep versus death.
Death rate.
If you sleep too little you'll probably die younger.
And if you sleep too much you'll probably die younger.
29:32So there's sort of a sweet spot in how much sleep you might get.
I didn't write the book.
And you say of course it's obvious if you sleep 0 hours a day you're probably gonna die.
And if you sleep 24 hours a day you're also probably going to die.
So there's sort of an optimal as we say in calculus there's an optimal number of hours to sleep.
Whatever it is you guys are sub-optimal I'm sure.
30:01Except on the weekends.
Fall asleep at 4 in the morning, also known as passing out.
Wake up some time in the middle of the afternoon. Wow what time is it I'm going back to bed. Don't wake me.
You mom's texted you 3 times and you ignore that.
And then later you go oh my phone wasn't working.
"How are you?" "I'm not feeling that well." "Maybe it's something I had last night."
30:30Yeah. Maybe it was.
I never experienced that of course. I was pure when I was in college.
Let's see they give us average number of hours of sleep versus death rate. And this is death per one hundred thousand males.
Also known as men.
They have this great picture in the book is a guy passed out on a stack of books.
31:051121, 805, 626, 813, 967.
I don't know where they come up with this nonsense data.
I mean how would you actually measure the number of hours that somebody sleeps?
It's different from day to day. Some people are sleeping right now in my class for example.
And then you would want to sort of average and if you're asleep...
31:43Anyway this kinda looks like this.
So there's a sweet spot.
But you know what about waking up in the middle of the night? What about the quality of your sleep?
And all of this but for a ??
So you look at that and you say well it looks like somewhere in the 7 to 8 range seems to be the best.
32:04These two numbers are kind of equal.
And these two numbers are kind of equal.
When I say kind of equal it's out of one hundred thousand.
And you could take a different hundred thousand people. This is one hundred thousand men, males.
Well, people who identify as male.
And you could do a different 100,000 people. You could do 100,000 women. You might get slightly different numbers.
But if you're dealing with a lot of these studies you probably will get something that's sort of a quadratic shape.
32:32And what does that tell you?
That says, let's say they come up with 7.2 hours.
Then that means that every night when you go to bed you should set the alarm for 7 hours and 12 minutes after when you go to bed and you'll wake up and you'll live a really really long time.
And then you do that for like 3 days and then you get hit by a bus.
Oops. That didn't work.
And then your friend who is a bum and sleeps for 14 hours a day lives to be 117.
33:02So that throws the data off. That's why you do 100,000 people.
But you can model this. We're not going to.
You know there's different kinds of modeling programs ?? is another one built in.
But the exponential model is generally the one that you're gonna see the most in the business world.
So like I said the internet growth is a good one.
33:32They had one in the book but I don't know if I really wanna do that one.
So you're selling, I don't know smartphones is a good example. You guys all have smartphones.
The new apple is coming out soon. It's gonna be like $1,000.
You going to get the new phone? Or are your parents going to say you can pay for this one.
You say well they're not going to keep my Apple 6 or whatever the heck you and your friends got.
Maybe I'll keep that another year.
Yeah the new phones gonna be 1,000 bucks. The new Samsung and new Apple. Well my response is I have an LG.
34:06LG is fine.
It's a great phone. It has a great camera.
I'm very happy. I can change the battery. Which you can't.
So when my battery dies I buy a new battery online for $8. You take it to the geniuses and they convince you to spend $1,000 on a new phone so I win.
So what happens is people will start to say I've got enough smartphones for now. $1,000 is a lot though.
That's not just a phone anymore. You're paying for a full computer at this point.
34:32They're betting they can sell lots of those. I think you're gonna get a flattening out.
Okay so I think an exponential model is realistic. That's sort of upside down exponential because you remember I drew these curves on Friday.
Remember what exponentials look like.
Generally the curve y = some number to the x looks like this.
35:05If it's growing. Or it looks like this if it's decaying.
But something that goes like this is also an exponential model.
Or really a logarithmic model they're really kind of the same thing.
It's just you took this and sort of flipped it upside down it's just you played with the equation a little bit.
But this is much more typical of what you'll see on certain kinds of sales models.
35:35Now car sales. If you're looking at the sales of your model of car you know let's say Honda Accords, they kind of sell the same amount every year. There's an initial burst where people go "Oh this is a nice car".
And then they kind of you know they count on so many hundreds of thousands or millions of Honda Accords sold every year.
It doesn't really change much from year to year.
So that's more like a linear model.
36:01But if you look at overall car sales in the economy, people are keeping their cars longer and so they're less likely to buy new cars than they were in the past.
So the number of new car buys is sort of flattening out.
Oh and we have population growth.
You got a car and someday you'll get cars for your children. That'll be your punishment.
Remember when you begged your parents for a car?
Now you get to get one for your kids and you turn to your parents and say you're grandparents you should be doing this.
36:36And they'll laugh at you.
But let's find a good example of an exponential model.
Here's a good one.
Anyone go to Starbucks this morning? That place is packed.
Let's do something with Starbucks.
37:13Years since 2010 I bought my Starbucks stock back in 1998 I think.
That was a smart move.
Don't worry I've made some dumb moves. I bought Amazon at $17 and sold it at $70 because I think that's high enough.
37:36You know where Amazon is now?
It's over $1,000. Oops.
But I made money. So making money isn't wrong I just, you know well.
I said come on it can't go up that much.
The question is would you buy Amazon stock now?
At $1,000. Do you think it's going to $1,500?
38:02I don't know. Hard to know anymore.
It's such an absurd price. But it might be.
A lot of people are betting it's going to keep going up.
They seem to be making a lot of money. So this is the price of one share of Starbucks stock.
You know Starbuck was a character in Moby Dick.
38:30That's what it's named for.
That's why they have that little sort of mermaid thing on the logo.
Okay is a linear model appropriate? Well stocks don't go up forever.
Well in theory something can be priced to infinity.
Or go up for a long time. So Berkshire Hathaway stock just keeps going up and up.
39:00If you bought one share of Berkshire Hathaway in the 60's- I forget what it was $100 or something?
It's worth a few thousand dollars or a few hundred thousand dollars now.
So that was a good investment.
That's why Warren Buffet is fabulously rich because he owns all that Berkshire Hathaway stock.
If you don't know about these things by the way since you guys are all business students you need to start developing your business news trivia information brain.
39:31So start finding any sorts of information and learn a little bit about it everyday.
Get the Bloomberg app that's really good.
Bloomberg is a big, they're an overall news organization but they focus on financial news.
Wall Street Journal app is very good. NY Times business section.
But start learning everyday look up some of those headlines. Start paying attention to things like what the stock market is, interest rates, the fed, it's a 15 minute investment. There's gonna come a point in a couple of years where you're going to be interviewing
40:02and your interviewer is going to expect you to know when he or she says Berkshire Hathaway that that's Warren Buffet's corporation.
You wanna know these things I mean when I started business school I didn't know anything either.
You wanna make sure that you have all of this stored away so you can bring it up in conversation or if they bring it up you can at least nod knowingly and act as if you know what they're talking about.
Which is usually most ?? If you look and go I don't know who ?? is then they're gonna be like okay well one point against you.
40:35You wanna kinda of try to develop these skills so if you look in your phone Wall Street Journal app, Bloomberg, the Yahoo finance page is very good, that's probably the best of the finance pages.
Any of those things. And it doesn't have to just do with the financial part of business.
There's marketing, advertising, the economy, all this stuff. It sounds like a big investment in time but it's really not.
It will take a little time away from cat videos but not a lot.
41:03Which I find incredibly uninteresting personally, but you know you wanna watch a cat playing with a ball you think that's fun feel free. If we were to plot this we would say well we started at about 20 then let's see.
We went up to 30 so we'll call that 20.
41:4030, 40, 50, 60, 70.
Okay so you got that and you've got that.
It looks like a line it's kind of curved a little bit though.
42:04So if we added more data points and I plotted more carefully it's kinda looking more like that.
And then you run this through your computer and you get that the price of the stock is about $21.76 * 1.38^x
42:34That's pretty big.
That says this is growing 38% per year.
Wow. Okay, but generally that would say the Starbucks stock is growing exponentially which means that it's growing faster and faster which means you definitely want to own some Starbucks stock its accelerating.
Makes sense?
So how would you generate this? Well you wouldn't.
You'd have a computer program do that for you.
43:02That's very hard to come up with that number but a linear model is probably not terrible either.
We only have 5 data points of course if you were really doing this you could get data on a Starbucks stock in a second.
Certainly you could do daily, weekly, monthly data and get much more of a picture.
And then one of the things you can do is you can go to your phone or your computer and pull up the actual chart for Starbucks and see what it does. Of course it's gonna jerk all over the place but you can make a trend line that gives you a feel for how Starbucks stock is gonna behave.
43:33Alright so we're starting limits on Wednesday. I'll put the video page up. Everybody have a nice day.