You are on page 1of 56

COMPUTATIONAL

METHODS
&
STATISTICS
MTH 2212
LECTURER
DR ZAHARAH WAHID
EXT 4514, ROOM E1-4-8-13
COURSE EVALUATION & ASSESSMENT

Evaluation & Assessment Percentage


Quizzes ( Class) 3x for each section 10%

Group mini- project 5%

Assignments 5%

Mid-term examination 17th Mar 2016 30%

Final Examination 50%


2
Course Objectives
• Enhance ability to extract meaningful
information from data sets

• Improve decision making abilities

• Learn new ways to look at data

• Gain confidence in the use of statistical methods

3
Population & Sample
• POPULATION : The set of all
measurements of interest to the
experimenter

• SAMPLE: A subset/portion of
measurements selected from the
population of interest for analysis.

4
Examples

• Total items produced on a machine each


year from 2000 to 2005- population

• A group of 25 patients selected to test a


new drug-sample

5
SYMBOL

Measurement Sample Population

Mean × 

Variance S2 2
Standard
Deviation S 

6
Type of Statistics

• DESCRIPTIVE STATISTICS:
Procedures used to summarize and
describe the set of measurements.

• INFERENTIAL STATISTICS:
Procedures used to draw conclusions or
inferences about the population from
information contained in the sample
7
Types of data

Variable (Quantitative)
Measurable characteristic
e.g: height, length, thickness

Attribute (Qualitative)
Qualitative data (count)
e.g: yes/no, OK/NG, go/no go

8
Definition
Probability & Chance
An experiment is a situation involving chance or
probability that leads to results called outcomes.

An outcome is the result of a single trial of an


experiment.

An event is one or more outcomes of an experiment.

Probability is the measure of how likely an event is.


The Probability
of an Event
• P(A) must be between 0 and 1.
– If event A can never occur/impossible, P(A) = 0.
– If event A always occurs/certain when the
experiment is performed, P(A) =1.
• This can only be applied when all the
outcomes of the experiment are equally likely.

•P(A)= # of favorable outcomes/# of all


total possible outcomes
10
Counting Techniques
Multiplication& Additional
Rules
“AND” is understood to mean “
multiply”

“OR “ is understood to mean “ add”


Counting Techniques
Multiplication& Additional
Rules
 E1 can occur in 3 ways ( A, B, C) and E2 can
occur in 2 ways (P,Q) then the combination
of E1 and E2 can occur in 3X2 ways
 A bag contains seven balls, numbered from
1 to 7, A ball is drawn from the bag. If the
number is even than a coin is tossed. If the
number is odd, then a die is thrown. How
many outcomes are possible?
1st outcome=[even #] and [toss a coin]
= [3] x [2]= 6

2st outcome= [odd #] and [throw a die]


=[4] x [6] 24

1st outcome + 2nd outcome= 6+24 = 30


Multiplication& Additional
Rules

Rolling a die possible outcomes(that are


equally likely)
P(4)= P(not 4)= P(8)=

P(odd or even)= P( less than 3)=


m
Permutation m

Permutation n different objects


Example: 5 students in a row to take a group
photo. How many different standing
arrangements can the students form for the
photo session?
Pnn 
n! n(n  1)(n  2)...(2)(1)
Number of different standing arrangements = 5!
= 5!
=5x4x3x2x1
15
Permutations
• The number of ways you can arrange
n distinct objects, taking them r at a time is
n!
Pr 
n

(n  r )!
where n! n(n  1)(n  2)...(2)(1) and 0! 1.
Example: How many 3-digit lock combinations
can we make from the numbers 1, 2, 3, and 4?
The order of the choice is important! 4!
P   4(3)(2)  24
3
4

1!
16
Examples
Example: A lock consists of five parts and can
be assembled in any order. A quality control
engineer wants to test each order for
efficiency of assembly. How many orders are
there?
The order of the choice is important!

5!
P   5(4)(3)(2)(1)  120
5
5

0!
17
Permutation of n objects for given conditions

1. Use multiplication rule


2. Consider the conditions

Find the number of 5-digit odd numbers


that can be formed using the digits 3, 4,
5, 6, and 7 without repetition

Last digit

4! ways 3 ways choosing odd #

Number of 5-degit odd numbers = 4! X 3 = 72


18
Permutation of n different objects taken r at a
time for given conditions
How many 4-digit number that are less
than 7000 can be formed using the
digits 2, 4, 5, 7 and 8 without
repetition?

Number of digit less than 7000


=3x 4P3
4!
=3 x = 3x4x3x 2= 72
(4  3)!
19
Example
In how many different ways can all the letters in
the word “PRINT” be arranged without
repetition/replacement?

There are 5 different letters in the word PRINT

Therefore, number of different arrangements


n!= 5!
= 5x4x3x2x1 =120

21
Example
In general, If there are a total of n objects, out of
which p of them are the same object, q of another
object, r of another object and so on, then the total
𝑛!
number of arrangements is
𝑝!𝑞!𝑟!

In how many different ways can all the letters in the


word “DADAH” be arranged without repetition?

There are 5 different letters in the word DADAH

Therefore, number of different arrangements


= 5!/2!2!
22
23
Exercise
How many digits number can be formed with 5
digits 1,2,3,4,5 if
a) repetitions are allowed
b) repetitions are not allowed
c) the number is odd and no repetitions are
allowed
d)the number is even and repetitions are
allowed
(e) The number is greater than 50,000 and no
repetitions are allow
24
m
m
SOLUTION

(a) repetitions allowed


5 x 5 x 5 x 5 x 5 =3,125

(b) no repetitions

5 X 4 X 3 X 2 X 1 =72

25
SOLUTION
(c) number is odd and no repetitions the last
place can be filled in only 3ways(1,3,5), then
fill in the other places.
4 X 3 X 2 X 1 X 3 =72

( d) number is even and repetitions allowed .


The last place can be filled in (2 or 4). Fill this
in first, then fill in the other places

5 x 5 x 5 x 5 x 2=1,250

26
Cont… m
m

(e)Greater than 50,000 &no repetitions


The first place can be filled in only 1
way(with 5). Fill this first, then fill in
other places.
1 X 4 X 3 X 2 X 1 =24

27
Example
There are 5 women and 4 men in a club. A team of
four has to be chosen. How many different teams
can be chosen if there must be either exactly one
women or exactly two women on the team?
and= x or=+
A team must consist 4 people.
Suppose W denotes a women and M denotes a man

1W and 3M or 2W and 2M

𝐶15 𝑋 𝐶34 = 20 𝐶25 𝑋 𝐶24 = 60


= 20+60
28
m
m

Example
A,B,C,D,E and F are six nurses. How many different
ways can they be seated in a row if
(a) there are no restrictions on the seating
(b) A and B must sit beside each other
(c) A and B must not sit beside each other
(d)D, E, and F must sit beside each other
(e) A and F must sit at the end of each other
Solution
(a)No restrictions
number of arrangements= 6 x 5 x 4 x 3 x 2 x1 =6!=720

(b) A and B must sit beside each other


Consider A and B as one person
A,B, C D, E, F
5 persons can be arranged in 5! Ways
But A and B can be arranged in 2! ways while seated together (AB,
BA).
So the number of arrangements = 2! X 5! =2 X 120 =240

( c) A and B must not sit beside each other


𝑛𝑜. 𝑜𝑓
𝑡𝑜𝑡𝑎𝑙 𝑛𝑜. 𝑛𝑜. 𝑜𝑓 𝑎𝑟𝑟𝑎𝑛𝑔𝑒𝑚𝑒𝑛
𝑎𝑟𝑟𝑎𝑛𝑔𝑒𝑚𝑒𝑛𝑡𝑠 = −
𝑜𝑓 𝑎𝑟𝑟𝑎𝑛𝑔𝑒𝑚𝑒𝑛𝑡𝑠 𝑤𝑖𝑡ℎ 𝐴 𝑎𝑛𝑑 𝐵 𝑡𝑜𝑔.
𝑤𝑖𝑡ℎ 𝐴 𝑎𝑛𝑑 𝐵 𝑛𝑜𝑡 𝑡𝑜𝑔𝑒𝑡ℎ𝑒𝑟
30
Cont…..
= 720-240=480
D, E, and F must sit beside each other.
(d) Consider D, E, and F as one person
A, B, C D, E, F
4 person can be arranged in 4 ways, but D, E and F
can be arranged in 3! Ways while seated together
so the number of arrangements = 3! X4! =6x24 =144

( e) A and F must sit at the end of each other.


Put A and F at the ends and B,C,D and E in between them
B, C, D and E can be arranged in 4! ways seated together. A and
F can exchange places. No. of arrangements= 2!X 4!= 2X 24=48

31
Combinations
• The number of distinct combinations of n
distinct objects that can be formed, taking
them r at a time is n!
Cr 
n

r!(n  r )!
Example: Three members of a 5-person committee must
be chosen to form a subcommittee. How many different
subcommittees could be formed?
5! 5(4)(3)(2)1 5(4)
The order of
C 
5
   10
3!(5  3)! 3(2)(1)(2)1 (2)1
the choice is 3
not important!

32
Example1
Combination of r objects chosen from n
different objects for given conditions

2 boys and 3 girls are to be selected from a


group of 6 boys and 7 girls to form a badminton
team. In how many ways can the team be
formed?

Number of ways choosing 2boys from 6 boy = 15


Number of ways choosing 3girls from 7 boy = 35
15 x 35 =525

33
Example 3
There are 10 pens in a box, 6 red and 4 green.
If 3 are picked out at random, what is the
probability of 1 red and 2 green?

The number of ways of picking 3 pens from 10 in


which the order does not matter
10!
𝐶310 = = 120
3! 10−3 !

P( 1 red and 2 green) = 𝐶16 𝑋 𝐶24 = 36


= 36/120 =0.3

34
Exercise
A bag contains 9 white and 6 black
balls. What is the probability of selecting
(i) 2 white balls
(ii) 3 white balls
(iii) 4 black balls
(iv) 1 white and 3 black balls
(v) 4 white and 5 black balls

Ans: 9C2/15C2, 9C3/15C3, 6C4/15C4, 9C1 x 6C3 /15C4,


9C4 x 6C5 /15C9
35
Exercise
There are 4 men and 5 women. Find the probability of
selecting 3 of which
(i) exactly two are women
(ii) no woman
(iii) at least one women
(iv) at most one women
(v) no men

Ans:5C2 x 4C1/, 9C3 4C3/9C3, (5C1 x 4C2 + 5C2 x 4C1 + 5C3)/9C3, 4C3 +
5C1 x 4C2 )/9C3, 5C3/9C3

36
m
Tree diagram m
Example 3
A box contains 24 transistors, 4 of which are
defectives. If 4 are sold at random, find the
following probabilities
I. Exactly 2 are defectives
II. None is defective
III. All are defectives
IV. At least one is defective
I. Exactly 2 are defectives
𝐶24 𝑋 𝐶220 1140
P( exactly 2 defectives) = =
𝐶424 10,626

2. None is defective
No. of ways to choose no defectives is 𝐶420
P( no defectives) = 𝐶420 /𝐶424 = 4845/10,626=1615/3542

3. All are defectives


P( all defectives) = 𝐶44 /𝐶424 = 1/10,626

4.P( at least 1 defectives) = 1- P(no defectives) =1-


4845/10,626 = 1- 1615/3542 =1927/3542
Probability Distributions for Discrete
Random Variables
• The probability distribution for a discrete
random variable x resembles the relative
frequency distributions. It is a graph, table or
formula that gives the possible values of x and
the probability p(x) associated with each
value.

We must have
0  p( x)  1 and  p( x)  1
Probability Distributions
• Probability distributions can be used to describe
the population, just as we described samples in
handout 1.
– Shape: Symmetric, skewed, mound-shaped…
– Outliers: unusual or unlikely measurements
– Center and spread: mean and standard
deviation. A population mean is called  and a
population standard deviation is called .
Example
• The probability distribution for x the
number of heads in tossing 3 fair
coins.
Symmetric; mound-
• Shape? shaped

• Outliers? None

• Center?  = 1.5

• Spread?  = .688


Key Concepts
V. Discrete Random Variables and Probability
Distributions
1. Random variables, discrete and continuous
2. Properties of probability distributions
0  p( x)  1 and  p( x)  1
3. Mean or expected value of a discrete random
variable: Mean :    xp( x)
4. Variance and standard deviation of a discrete
random variable: Variance :  2  ( x   ) 2 p( x)
Standard deviation :    2
Example
• Toss a fair coin three times and
define x = number of heads.
x
HHH 1/8
3
x p(x)
P(x = 0x) = 1/8 0 1/8
HHT 1/8 2 P(x = 1) = 3/8 1 3/8
HTH 1/8 2
P(x = 2) = 3/8 2 3/8
THH P(x = 3) = 1/8
1/8 2 3 1/8
HTT
1/8 1
Probability Histogram
THT for x
1/8 1

TTH
1/8 1

TTT 0
1/8
The Mean
and Standard Deviation
• Let x be a discrete random variable with
probability distribution p(x). Then the mean or
expected value, variance and standard
deviation of x are given as

Mean :   E ( x)   xp ( x)
Variance :   ( x   ) p( x)
2 2

Standard deviation :    2
Example
• Toss a fair coin 3 times and
record x the number of heads.
x p(x) xp(x) (x-)2p(x) 12
0 1/8 0 (-1.5)2(1/8)    xp ( x)   1.5
8
1 3/8 3/8 (-0.5)2(3/8)
2 3/8 6/8 (0.5)2(3/8)
3 1/8 3/8 (1.5)2(1/8)
  ( x   ) p( x)
2 2

 2  .28125  .09375  .09375  .28125  .75


  .75  .8660
Example
• Relative frequency.
x p(x) f fx
0 1/8 1 0x1=0
1 3/8 3 1x3=3
2 3/8 3 2x3=6
3 1/8 1 3x1=3
Expectation Value, E(X)
Mean :   E ( X )   xp( x)
Variance of X is written as Var(X)  E ( X   ) 2 p ( X  x)
 E( X   )2
Var ( X )  E ( X 2 )  [ E ( X )]2

x 0 1 2 3
Given: P(X=x) 1/8 3/8 3/8 1/8

Find the expected value of X, variance of X

E (X) = 𝑥𝑃 𝑋=𝑥
1 3 3 1 12
=0 +1 +2 +3 = = 1.5
8 8 8 8 8
Cont,……

E (𝑋 2 ) = 𝑥 2 𝑃(𝑋 = 𝑥)
2
1 2
3 2
3 2
1
= 0 +1 +2 +3 = 3
8 8 8 8

Var ( X )  E ( X 2 )  [ E ( X )]2
= 3 − (1.5)2
= 0.75

49
Probability Distributions Table
Find P( X > 1)

x 0 1 2 3
P(X=x) 1/8 3/8 3/8 1/8

P( X > 1) = P( X=2 or 3)
=P(X=2) + P(X=3)
= 3/8 + 1/8
= 4/8
= 1/2
The discrete random variable X has probability

X 1 2 3 4 5 6 7
P(X= 0.1 0.2 0.1 0.2 0.1 0.2 0.1
x)

Show that X is a discrete random variable. Hence, find

i) P( X< 4)
ii) P( 3< X  6
iii) E(X)
PDF and CDF DISCRETE
Cumulative density function –CDF
Definition
𝐹 𝑥 = 𝑃( 𝑋 ≤ 𝑥 )
Properties -CDF

1. 0 ≤ 𝐹 𝑥 ≤ 1 , -∞<𝑥 < ∞
2. 𝐹 −∞ = 0, 𝐹 ∞ = 1
3. if 𝑥1 < 𝑥2 𝑡ℎ𝑒𝑛 𝐹 𝑥1 ≤ 𝐹(𝑥2 )
4. 𝑃 𝑥1 < 𝑋 ≤ 𝑥2 = 𝐹 𝑥2 − 𝐹(𝑥1 )
Note
P( X > 𝑥1 ) = 𝑃 𝑥1 < 𝑋 < ∞ = 𝐹 ∞ − 𝐹 𝑥1
= 1− 𝐹(𝑥1 )
Example 1
𝑥 0 1 2
P( X = 𝑥 ) 1/4 2/4 1/4
F(𝑥 ) 1/4 3/4 1

Find , F( 2) = 1
Find, F(1) = ¾
P( 0 ) + P( 1)

Find, F( 1.7) = F ( 1)
Exercise
𝑥 3 5 6 8 9
P( X = 𝑥 ) 0.1 0.2 0.1 0.5 a
F(𝑥 )

P( X > 𝑥1 ) = 1
Find
1. a,
2. F(9),
3. F( 6)
Example 2- how to find PDF
𝑥 4 7 9 11
F(𝑥 ) 0.3 0.4 0.9 1
P( X = 𝑥 ) 0.3 0.1 0.5 0.1

Find , P( 𝑥 =7) ?
F( 7 ) - P( 4)
Find, P(𝑥 = 9)?
Find, F( 1.7) = F ( 1)