computer applications for engineers - thammasat university - 0 - introduction.pdf · marilyn vos...

55
Asst. Prof. Dr. Prapun Suksompong [email protected] Introduction 1 Computer Applications for Engineers ET 601 Office Hours: BKD 3601-7 Thursday 14:40-16:00 Wednesday 9:30-11:30

Upload: others

Post on 20-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Asst. Prof. Dr. Prapun Suksompong [email protected]

Introduction

1

Computer Applications for Engineers ET 601

Office Hours:

BKD 3601-7

Thursday 14:40-16:00

Wednesday 9:30-11:30

Page 2: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Eye Examination

2

Are you sitting too far away?

You should be able to read this line,

and this line,

and this line.

Page 3: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Course Organization

3

Course Website:

http://www2.siit.tu.ac.th/prapun/ET601/

Lectures:

Wednesday 13:00-16:00 BKD 3206

Textbook: “Simulation”

By Sheldon M. Ross

5th Edition

Academic Press

2012

ISBN-10: 0124158250

ISBN-13: 978-0124158252

i

Page 4: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Course Web Site

4

Please check the course website regularly.

Announcements

References

Handouts (Posted before corresponding

lectures)

Slides (Posted after corresponding lectures)

Calendar

Lectures

Exercises and projects due dates

Presentation Slots

www2.siit.tu.ac.th/prapun/ET601/

i

Page 5: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Course Web Site

5

prapun.com

Page 6: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Course Website: Notes & Slides

6

I frequently use Microsoft OneNote on my tablet instead of the whiteboard. The files will be exported as pdf and posted after the corresponding lectures.

PDF notes (if any) will be posted before the corresponding lectures.

In lectures…

PDF notes and slides will be annotated.

The slides and updated notes will be posted on the course website after the corresponding lectures.

Remind me the day after the lecture if the notes/slides from the day before are still not posted on the web.

i

Page 7: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Me?

7

Ph.D. from Cornell University, USA

In Electrical and Computer Engineering

Minor: Mathematics (Probability Theory)

Ph.D. Research: Neuro-Information Theory

Modeling and analyzing neurons in human brain from communication engineering perspective.

Current Research: Wireless Communication

Mobile Communications, WiFi (802.11)

2009 SIIT Best Teaching Award

2011 SIIT Research Award

prapun.com

i

Page 8: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Synopsis

8

Main Focus: Model random phenomenon and use

simulation study to analyze it.

Page 9: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Motivation

9

Formulation of model to describe and study a real phenomenon

Traditional choices: choosing a model that is a realistic replica of the actual situation choosing one whose mathematical analysis is tractable.

Traditional tradeoff: Can’t choose a model that is faithfully conformed to the phenomenon

under study if it were not possible to mathematically analyze that model.

Concentration on asymptotic or steady-state results as opposed to the more useful ones on transient time.

New Approach: Relatively recent advent of fast and inexpensive computational power has opened up another approach-namely, to try to model the phenomenon as faithfully as possible and then to rely on a simulation study to analyze it.

Page 10: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Goals

10

Main Focus: Model random phenomenon and use

simulation study to analyze it.

To do this…

Use a computer to generate random (more precisely,

pseudorandom) numbers.

Use these random numbers to generate the values of random

variables from arbitrary distributions.

Use random variables to generate the behavior of a stochastic

model over time.

Page 11: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Asst. Prof. Dr. Prapun Suksompong [email protected]

1 Review of Basic Probability

11

Computer Applications for Engineers ET 601

Office Hours:

BKD 3601-7

Thursday 14:40-16:00

Wednesday 9:30-11:30

Page 12: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

References

12

Chapter 14 (Review of Basic Probability)

In “Operations Research: An Introduction”

By Hamdy A. Taha

2011, 9th Edition

Prentice Hall

Chapter 2 (Elements of Probability)

In “Simulation”

By Sheldon M. Ross

2012, 5th Edition

Academic Press

My undergraduate course on probability

http://www2.siit.tu.ac.th/prapun/ecs315/

Page 13: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Recommended Reading

13

Understanding Probability: Chance Rules in Everyday Life

By Henk Tijms

Call No. QA273 T48 2012

Cambridge University Press

“Part One” provides many motivating examples and problems from everyday life

“Part Two” teaches clearly and simply the mathematics of probability theory.

Sample materials are available at the author’s website: http://personal.vu.nl/h.c.tijms/

http://www.cambridge.org/aus/catalogue/catalogue.asp?isbn=9781107658561&ss=exc

2nd Edition (2007)

3rd Edition (2012)

Page 14: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

14

Randomness

Page 15: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

15

Life is random

Page 16: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

16

Life is random

In 2005, this statement (which is true)

showed up all over the world…

Page 17: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

17

Life is random

Page 18: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

“Random”-ness

18

Most people have preconceived notions of randomness

that often differ substantially from true randomness.

Truly random data sets often have unexpected properties

that go against intuitive thinking.

These properties can be used to test whether data sets have

been tampered with when suspicion arises.

Page 19: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Success Runs (1/4)

19

Suppose that two people are separately asked to toss a fair

coin 120 times and take note of the results. Heads is noted

as a “one” and tails as a “zero”.

Results: Two lists of compiled zeros and ones:

[Tijms, 2007, p 192]

Page 20: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Success Runs (2/4)

20

Which list is more likely?

[Tijms, 2007, p 192]

Page 21: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Success Runs (3/4)

21

Fact: Suppose we know that one of the two individuals has

cheated and has fabricated a list of numbers without having

tossed the coin.

Which list is more likely be the fabricated list?

[Tijms, 2007, p 192]

Page 22: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Success Runs (4/4)

22

Fact: In 120 tosses of a fair coin, there is a very large probability that at some point during the tossing process, a sequence of five or more heads or five or more tails will naturally occur. The probability of this is approximately 0.9865.

In contrast to the second list, the first list shows no such sequence of five heads in a row or five tails in a row. In the first list, the longest sequence of either heads or tails consists of three in a row.

In 120 tosses of a fair coin, the probability of the longest sequence consisting of three or less in a row is equal to 0.000053 which is extremely small .

Thus, the first list is almost certainly a fake.

Most people tend to avoid noting long sequences of consecutive heads or tails. Truly random sequences do not share this human tendency!

[Tijms, 2007, p 192]

Page 23: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

“The Perfect Thing”

23

What is this?

Page 24: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

“The Perfect Thing”

24

Page 25: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

What about the shuffle function?

25

http://ipod.about.com/od/advanceditunesuse/a/itunes-random.htm

http://electronics.howstuffworks.com/ipod-shuffle2.htm

http://www.cnet.com.au/itunes-just-how-random-is-random-339274094.htm

Page 26: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Shuffle function on iPod

26

Apple ran into an issue with the random shuffle method it

initially employed in its iPod music players:

true randomness sometimes produces repetition

When users heard the same song or songs by the same artist

played back-to-back, they believed the shuffling wasn’t

random.

So the company made the feature “less random to make it

feel more random,” said Apple founder Steve Jobs.

Page 27: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Monty Hall Problem (MHP): Origin

27

Problem, paradox, illusion

Loosely based on the American television game show

Let’s Make a Deal. (Thai CH7 version: ประตูดวง.)

The name comes from the show’s original host, Monty

Hall.

One of the most interesting mathematical brain teasers of

recent times.

Page 28: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Monty Hall Problem: Math Version

28

Originally posed in a letter by Steve Selvin to the American

Statistician in 1975.

A well-known statement of the problem was published in

Marilyn vos Savant’s “Ask Marilyn” column in Parade

magazine in 1990: “Suppose you're on a game show, and

you're given the choice of three doors:

Behind one door is a car; behind the others,

goats. You pick a door, say No. 1, and the

host, who knows what's behind the doors,

opens another door, say No. 3, which has a

goat. He then says to you, "Do you want to

pick door No. 2?" Is it to your advantage to

switch your choice?”

Page 29: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Marilyn vos Savant

29

Vos Savant was listed in each edition of the Guinness Book

of World Records from 1986 to 1989 as having the “Highest

IQ.”

Since 1986 she has written “Ask Marilyn”

Sunday column in Parade magazine

Solve puzzles and answer questions from readers

[ http://www.marilynvossavant.com ]

Page 30: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

MHP: Step 0

30

There are three closed doors.

They look identical.

Page 31: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

MHP: Step 0

31

Behind one of the doors is the star prize - a car.

The car is initially equally likely to be behind each door.

Behind each of the other two doors is just a goat.

Page 32: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

MHP: Step 1

32

Obviously we want to win the car, but do not

know which door conceals the car.

We are asked to choose a door.

That door remains closed for the time being.

“Pick one of

these doors”

Page 33: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

MHP: Step 2

33

The host of the show (Monty Hall), who knows what is behind

the doors, now opens a door different from our initial choice.

He carefully picks the door that conceals a goat. We stipulate that if Monty has a choice of doors to open, then he chooses randomly from among his options.

Page 34: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

MHP: Step 3

34

Monty now gives us the options of either

1. sticking with our original choice or

2. switching to the one other unopened door.

After making our decision, we win whatever is behind our door.

“Do you want

to switch

doors?”

Page 35: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Monty Hall Problem

35

Will you do better by sticking with your first choice, or

by switching to the other remaining door?

Make no difference?

Assuming that our goal is to maximize

our chances of winning the car, what

decision should we make?

Page 36: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

36

Let’s play!

Page 39: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

39

Back to the boring

administrative stuff!

Page 40: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Calendar

40

i

Lecture

M T W R F

11-Nov-13 12-Nov-13 13-Nov-13 14-Nov-13 15-Nov-13

18-Nov-13 19-Nov-13 20-Nov-13 21-Nov-13 22-Nov-13

25-Nov-13 26-Nov-13 27-Nov-13 28-Nov-13 29-Nov-13

2-Dec-13 3-Dec-13 4-Dec-13 5-Dec-13 6-Dec-13

9-Dec-13 10-Dec-13 11-Dec-13 12-Dec-13 13-Dec-13

16-Dec-13 17-Dec-13 18-Dec-13 19-Dec-13 20-Dec-13

23-Dec-13 24-Dec-13 25-Dec-13 26-Dec-13 27-Dec-13

30-Dec-13 31-Dec-13 1-Jan-14 2-Jan-14 3-Jan-14

6-Jan-14 7-Jan-14 8-Jan-14 9-Jan-14 10-Jan-14

13-Jan-14 14-Jan-14 15-Jan-14 16-Jan-14 17-Jan-14

20-Jan-14 21-Jan-14 22-Jan-14 23-Jan-14 24-Jan-14

27-Jan-14 28-Jan-14 29-Jan-14 30-Jan-14 31-Jan-14

3-Feb-14 4-Feb-14 5-Feb-14 6-Feb-14 7-Feb-14

10-Feb-14 11-Feb-14 12-Feb-14 13-Feb-14 14-Feb-14

17-Feb-14 18-Feb-14 19-Feb-14 20-Feb-14 21-Feb-14

24-Feb-14 25-Feb-14 26-Feb-14 27-Feb-14 28-Feb-14

3-Mar-14 4-Mar-14 5-Mar-14 6-Mar-14 7-Mar-14

10-Mar-14 11-Mar-14 12-Mar-14 13-Mar-14 14-Mar-14

17-Mar-14 18-Mar-14 19-Mar-14 20-Mar-14 21-Mar-14

Page 41: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Class Participation

41

If you come only to receive, you will fall asleep.

Do not simply sit quietly in the class.

Need interaction between the lecturer and students.

Ask question when there is something that you don’t understand.

Don’t be shy!

It is very likely that your peers don’t understand it as well.

If you already understand what I’m presenting, SHOW ME!

Point out the errors/typos.

I will raise many issues/questions in class. Try to comment on them.

i

Page 42: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Policy

42

We will start the class on time and will finish on time.

Time reference: Not the clock in classroom. Use time server.

Please come to class on time.

Raise your hand and tell me immediately if I go over the time limit.

Does NOT mean that I will leave the room immediately after lecture. I will stay and answer questions.

Mobile phones must be turned off or set in silent mode.

We may have some pop quizzes (without prior warning or announcement) and in-class exercises.

Pop quizzes will be taken/given irregularly and randomly.

Feel free to stop me when I talk too fast or too slow.

i

Page 43: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Tips

43

Almost everything including what I have written on my tablet

will be saved and posted on web soon after class.

No need to take detailed lecture notes (if you don’t want to).

Put all of your energy into understanding the

material.

Of course, there is always someone (in the class) who will take

good notes anyway and you can (potentially) borrow or make a

copy of the notes from them.

Have fun with the materials presented in class.

Page 44: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Remarks

44

Get as much legitimate help as you can

Participate actively in class and outside of class

If you feel that the class is very easy, you might overlook something.

If you feel that the class is very difficult, you are probably not the only one who feel that way.

Don’t give up. Chat with me.

It takes me a long time to feel comfortable with these materials; yet, I still make mistakes.

My notation can be different from the textbook.

Every notation has some advantages and disadvantages.

Page 45: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Policy: Summary

45

Please stop me if I go over the time limit.

Please stop me if I talk too fast.

Please stop me if you have any question.

i

Page 46: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Monty Hall Problem: a short revisit

46

Will you do better by sticking with your first choice, or

by switching to the other remaining door?

Make no difference?

Assuming that our goal is to maximize

our chances of winning the car, what

decision should we make?

Page 47: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Monty Hall Problem: vos Savant’s

Answer

47

“You double your chances of

winning by switching doors.”

Page 48: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Monty Hall Problem: Controversy

48

Approximately 10,000 readers,

including nearly 1,000 with PhDs

(many of them math professors),

wrote to the magazine

claiming the published solution was wrong.

“You blew it,” wrote a mathematician from George Mason

University.

From Dickinson State University came this: “I am in shock

that after being corrected by at least three mathematicians,

you still do not see your mistake.”

[Mlodinow, 2008, p 42-45]

Page 49: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Controversy (2)

49

From Georgetown: "How many irate mathematicians are needed to change your mind?"

And someone from the U.S. Army Research Institute remarked, "If all those Ph.D.s are wrong the country would be in serious trouble."

When told of this, Paul Erdős, one of the leading mathematicians of the 20th century, said, "That's

impossible."

Then, when presented with a formal mathematical proof of the correct answer, he still didn't believe it and grew angry.

Only after a colleague arranged for a computer simulation in which Erdős watched hundreds of trials that came out 2-to-1 in favor of switching did Erdős concede that he was wrong.

Page 50: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

MATLAB

50

In this class, we use MATLAB to

perform computer simulation.

Page 51: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

MATLAB Fundamentals: Academic Tutorial

51

Page 52: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

MATLAB Fundamentals: Academic Tutorial

52

Page 53: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

MATLAB Fundamentals: Academic Tutorial

53

Page 54: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Command Window

54

MATLAB expressions and statements are evaluated as

you execute them in the Command Window, and results of

the computation are displayed there too.

They are usually of the form:

variable = expression

or simply:

expression.

If the variable name and = sign are omitted, a variable ans

(for answer) is automatically created to which the result is

assigned.

Page 55: Computer Applications for Engineers - Thammasat University - 0 - Introduction.pdf · Marilyn vos Savant’s “Ask Marilyn” column in Parade magazine in 1990: “Suppose you're

Help

55