sp2170 doing science lecture 3: random variables, distributions, inductive & abductive...

20
SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics National University of Singapore 2 Science Drive 2 Singapore 117543 Email [email protected] http://www.math.nus.edu.sg/~matwml/courses/ Undergraduate/SPS_Doing/2006/ Tel (65) 6516-2749 1

Upload: maria-glenn

Post on 29-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

SP2170 Doing ScienceLecture 3: Random Variables, Distributions,

Inductive & Abductive Reasoning, Experiments

Wayne M. Lawton

Department of Mathematics

National University of Singapore

2 Science Drive 2

Singapore 117543Email [email protected]

http://www.math.nus.edu.sg/~matwml/courses/Undergraduate/SPS_Doing/2006/

Tel (65) 6516-2749

1

Page 2: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

2

References [1] Rudolph Carnap, An Introduction to the Philosophy of Science, Dover, N.Y., 1995.[2] Leong Yu Kang, Living With Mathematics, McGraw Hill, Singapore, 2004. (GEM Textbook)(1 Reasoning, 2 Counting, 3 Graphing, 4 Clocking, 5 Coding, 6 Enciphering, 7 Chancing, 8 Visualizing)MATLAB Demo Random Variables & DistributionsDiscuss Topics in Chap. 2-4 in [1], Chap. 1, 7 in [2]. Baye’s Theorem & The Envelope Problem, Deductive, Inductive, and Abductive Reasoning. Assign computational tutorial problems.

PLAN FOR WEEK 3 LECTURE

Page 3: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

RANDOM VARIABLES

3

The number that faces up on an ‘unloaded’ dice rolled on a flat surface is in the set { 1, 2, 3, 4, 5, 6 } and the probability of each number is equal and hence = 1/6

After rolling a dice, the number is fixed to those who know it but remains an unknown, or random variableto those who do not know it. Even while it is still rolling, a person with a laser sensor connected with a sufficiently powerful computer may be able to predict with some accuracy the number that will come up.This happened and the Casino was not amused !

Page 4: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

MATLAB PSEUDORANDOM VARIABLES

4

The MATLAB (software) function rand generatesdecimal numbers d / 10000 that behaves as if d is a random variable with values in the set {0,1,2,…,9999}with equal probability. It is a pseudorandom variable.

It provides an approximation of a random variable x with values in the interval [0,1] of real numbers such that for all 0 < a < b < 1 the probability that x is in the interval [a,b] equals b-a = length of [a,b]. These are called uniformly distributed random variables.

Page 5: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

PROBABILITY DISTRIBUTIONS

5

Random variables with values in a set of integers are described by discrete distributions

Uniform (Dice), Prob(x = k) = 1/6 for k = 1,…,6

Poisson Prob(x = k) = a^k exp(-a) / k! for k > -1 where k is the event that k-atoms of radium decay if a is the average number of atoms expected to

decay.

Binomial Prob(x = k) = a^k (1-a)^(n-k) n!/(n-k)!k!for k = 0,1,…,n where an event that has probability a occurs k times out of a maximum of n times and k! = 1*2…*(k-1)*k is called k factorial.

Page 6: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

PROBABILITY DISTRIBUTIONS

6

Random variables with values in a set of real numbers are described by continuous distributions

Uniform

Gaussian or Normal

b

a

x dxbax 2

2

2

)(

21 exp]),[(Prob

10for 1]),[(Prob baabdxbaxb

a

here meanand variance deviation, standard 2

Page 7: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

MATLAB HELP COMMAND

7

>> help histHIST Histogram.N = HIST(Y) bins the elements of Y into 10 equally spaced

containers and returns the number of elements in each container. If Y is a matrix, HIST works down the columns.

N = HIST(Y,M), where M is a scalar, uses M bins.

>> help randRAND Uniformly distributed random numbers.RAND(N) is an N-by-N matrix with random entries, chosen from a uniform distribution on the interval (0.0,1.0).RAND(M,N) is a M-by-N matrix with random entries.

Page 8: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

MATLAB DEMONSTRATION 1

8

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

2

4

6

8

10

12

14

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

2

4

6

8

10

12

14

16

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

5

10

15

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

2

4

6

8

10

12

14

16

Why do these histograms look different ?

Page 9: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

MATLAB DEMONSTRATION 2

9

>> x = rand(10000,1);>> hist(x,41)

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

50

100

150

200

250

300

Page 10: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

MORE MATLAB HELP COMMANDS

10

>> help randnRANDN Normally distributed random numbers.RANDN(N) is an N-by-N matrix with random entries,

chosen from a normal distribution with mean zero, variance one and standard deviation one.

RANDN(M,N) is a M-by-N matrix with random entries.

>> help sumSUM Sum of elements.For vectors, SUM(X) is the sum of the elements of X. For matrices, SUM(X) is a row vector with the sum over

each column.

6754

13 sum

Page 11: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

MATLAB DEMONSTRATION 3

11

>> s = -4:.001:4;>> plot(s,exp(s.^2/2)/(sqrt(2*pi)))>> grid

-4 -3 -2 -1 0 1 2 3 40

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

Page 12: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

MATLAB DEMONSTRATION 3

12

>> x = randn(10000,1);>> hist(x,41)

-5 -4 -3 -2 -1 0 1 2 3 40

100

200

300

400

500

600

700

800

Page 13: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

MATLAB DEMONSTRATION 3

13

>> x = rand(5000,10000);>> y = sum(x);>> hist(y,41)

2420 2440 2460 2480 2500 2520 2540 2560 25800

100

200

300

400

500

600

700

800

Page 14: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

CENTRAL LIMIT THEOREM

14

The sum of N real-valued random variables y = x(1) + x(2) + … + x(N) will be a random variable. If the x(j) are independent and have the same distribution then as N increases the distributions of y will approach (means gets closer and closer to) a Gaussian distribution.

The mean of this Gaussian distribution = N times the (common) mean of the x(j)

The variance of this Gaussian distribution = N times the (common) variance of the x(j)

Page 15: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

CONDITIONAL PROBABILITY

15

Recall that on my dice the ‘numbers’ 1 and 4 are red and the numbers 2, 3, 5, 6 are blue.

I roll one dice without letting you see how it rolls. What is the probability that I rolled a 4 ?

I repeat the procedure BUT tell you that the number is red. What is the probability that I rolled a 4 ?

This probability is called the conditional probability that x = 4 given that x is red (i.e. x in {1,4})

Bevent given A event of Prob)|(Prob BA

Page 16: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

CONDITIONAL PROBABILITY

16

If A and B are two events thenevent that BOTH event A and event B happen.

Common sense implies the following LAW:

)|(Prob)(Prob)(Prob BABBA

BA denotes the

Example Consider the roll of a dice. Let A be the event x = 4 and let B be the event x is red (= 1 or 4)

2/1)|(Prob,3/1)(Pr

6/1)(Pr)(Prob

BABob

AobBA

Question What does the LAW say here ?

Page 17: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

BAYE’s THEOREM

17

http://en.wikipedia.org/wiki/Bayes'_theorem

Prob(A) and Prob(B) are called marginal distributions.

cA

)Prob(A)A|Prob(B Prob(A)A)|Prob(B)(Prob cc B

for an event A, denotes the event not A

Question Why does ? 1ProbProb )(A(A) c

Question Why does

Question Why does

Prob(B)

Prob(A)A)|Prob(B)(Prob

B

Page 18: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

INDUCTIVE & ABDUCTIVE REASONING

18

http://en.wikipedia.org/wiki/Inductive_reasoningInductive reasoning is the process of reasoning in which the premises of an argument support the conclusion but do not ensure it. This is in contrast to Deductive reasoning in which the conclusion is necessitated by, or reached from, previously known facts.

http://en.wikipedia.org/wiki/Abductive_reasoning

The philosopher Charles Peirce introduced abduction into modern logic. In his works before 1900, he mostly uses the term to mean the use of a known rule to explain an observation, e.g., “if it rains the grass is wet” is a known rule used to explain that the grass is wet. He later used the term to mean creating new rules to explain new observations, emphasizing that abduction is the only logical process that actually creates anything new. Namely, he described the process of science as a combination of abduction, deduction and implication, stressing that new knowledge is only created by abduction.

Abductive reasoning, is the process of reasoning to the best explanations. In other words, it is the reasoning process that starts from a set of facts and derives their most likely explanations.

Page 19: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

EXPERIMENTS

19

http://www.holah.karoo.net/experimental_method.htm

Carnap p. 41 [1] “One of the great distinguishing features of modern science, as compared to the science of earlier periods, is its emphasis on what is called the “experimental method”. “

Question How does the experimental method differ from the method of observation ?

Question What fields favor the experimental methods and what fields do not and why ?

http://www.math.nus.edu.sg/~matwml/courses/Undergraduate/USC/2006/USC2001/Lecture_3.ppt Slides 1-5

Ideal Gas Law - one of the greatest experiments !

Page 20: SP2170 Doing Science Lecture 3: Random Variables, Distributions, Inductive & Abductive Reasoning, Experiments Wayne M. Lawton Department of Mathematics

TUTORIAL QUESTIONS

20

Question 1. The uniform distribution on [0,1] has mean ½ and variance 1/12. Use the Central Limit Theorem to compute the mean and variance of the random variable y whosehistogram is shown in vufoil # 13.

Question 2. I roll a dice to get a random variable x in {1,2,3,4,5,6}, then put x dollars in one envelope and put 2x in another envelope then flip a coin to decide which envelope to give you (so that you receive the smaller or larger amount with equal probability). Use Baye’s Theorem to compute the probability that you received the smaller amount CONDITIONED on YOUR FINDING THAT YOU HAVE 1,2,3,4,5,6,8,10,12 dollars. Then use these conditional probabilities to explain the Envelope Paradox.