Lecture 3: Variances and Binomial distribution
Download
Report
Transcript Lecture 3: Variances and Binomial distribution
Stats for Engineers: Lecture 3
Conditional probability
Suppose there are three cards:
A red card that is red on both sides,
A white card that is white on both sides, and
A mixed card that is red on one side and white on the other.
All the cards are placed into a hat and one is pulled at random and placed on a table.
If the side facing up is red, what is the probability that the other side is also red?
44%
1.
2.
3.
4.
5.
1/6
1/3
1/2
2/3
5/6
29%
14%
11%
3%
1
2
3
4
5
Conditional probability
Suppose there are three cards:
A red card that is red on both sides,
A white card that is white on both sides, and
A mixed card that is red on one side and white on the other.
All the cards are placed into a hat and one is pulled at random and placed on a table.
If the side facing up is red, what is the probability that the other side is also red?
Probability tree
Let R=red card, TR = top red.
1
1
3
1
3
1
3
Top Red
1
3
Top White
1
3
1
2
Top Red
1
6
1
2
Top White
Red card
1
White card
Mixed card
1
6
π π
β© ππ
π π
ππ
=
π ππ
1
= 3
1 1
3+6
=
2
3
Conditional probability
Suppose there are three cards:
A red card that is red on both sides,
A white card that is white on both sides, and
A mixed card that is red on one side and white on the other.
All the cards are placed into a hat and one is pulled at random and placed on a table.
If the side facing up is red, what is the probability that the other side is also red?
Let R=red card, W = white card, M = mixed card. Let TR = top is a red face.
For a random draw P(R)=P(W)=P(M)=1/3.
Total probability rule:
π ππ
= π ππ
π
π π
+ π ππ
π π π
1 1 1
1
=1× + × =
3 2 3
2
The probability we want is P(R|TR) since having the red card is the only way for the other
side also to be red.
This is
π ππ
π
π π
π π
ππ
=
π ππ
=
1
1×3
2
=
3
1
2
Intuition: 2/3 of the three red faces are on the red card.
Summary From Last Time
Bayesβ Theorem
π π΅π΄ π π΄
π π΄π΅ =
π π΅
Total Probability Rule:
π π΅ =
e.g. from
π π΄π΅ =
π π΄β©π΅
π π΅
π π΅ π΄π π(π΄π )
π
Permutations - ways of ordering k items: k!
Ways of choosing k things from n, irrespective of ordering:
πΆππ
π!
π
=
=
π
π! π β π !
Random Variables: Discreet and Continuous
Mean
π=πΈ π π
β‘ π π
=
π π π(π = π)
π
Means add:
ππ + ππ = ππ + ππ = π π + π π = πππ + πππ
Mean of a product of independent random variables
If π and π are independent random variables, then π π β© π = π π π(π)
ππ =
π π₯ β© π¦ π₯π¦ =
π₯
π¦
π π₯ π π¦ π₯π¦
π₯
=
π¦
π π₯ π₯
π₯
π π¦ π¦
π¦
= π π = ππ ππ
Note: in general this is not true if the variables are not independent
Example: If I throw two dice, what is the mean value of the product of the throws?
The mean of one throw is π =
6
π=1 ππ
π=π
1
1
1
1
1
1
=1× +2× +3× +4× +5× +6×
6
6
6
6
6
6
1 21
= 1+2+3+4+5+6 × =
= 3.5
6
6
Two throws are independent, so π1 π2 = ππ1 ππ2 = 3.52 = 12.25
Variance and standard deviation of a distribution
For a random variable X taking values 0, 1, 2 the mean π is a measure of the average
value of a distribution, π = β©πβͺ.
The standard deviation, π , is a measure of how spread out the distribution is
π(π = π)
π
π
π
π
Definition of the variance (=π 2 )
2
ππ22 β‘
β‘ var(π)
var(π) =
= ππ β
βππ 2 =
=
π β π 2 π(π = π)
π
π π = π2
Note that
πβπ
2
= π 2 β 2 π π + π2
= π 2 β 2 ππ + π2
= π 2 β 2π2 + π2
= π 2 β π2
So the variance can also be written
π 2 = var π = β©π 2 βͺ β π2 =
π 2 π π = π β π2
π
This equivalent form is often easier to evaluate in practice, though can be
less numerically stable (e.g. when subtracting two large numbers).
Example: what is the mean and standard deviation of the result of a dice throw?
Answer: Let π be the random variable that is the number on the dice
The mean is π = 3.5 as shown previously.
The variance is π 2 = 6π=1 π 2 π π = π β π2
1
= (12 + 22 + 32 + 42 + 52 + 62 ) × 6 β 3.52
=
91
6
β 3.52 β 2.917
π = 3.5
Hence the standard deviation is π = 2.917 β 1.71
π
π
Sums of variances
For two independent (or just uncorrelated) random variables X and Y the variance of
X+Y is given by the sums of the separate variances.
Why? If π has π = ππ , and π has π = ππ , then
π + π = π + π = ππ + ππ .
Hence since var π =
var π + π =
π β ππ
2
π + π β ππ β ππ
, if π = π + π then
2
= β© π β ππ + π β ππ
= β© π β ππ
2
+ π β ππ
2
2βͺ
+ 2 π β ππ π β ππ¦ βͺ
= β© π β ππ 2 βͺ + β© π β ππ 2 βͺ + 2β© π β ππ π β ππ¦ βͺ
If X and Y are independent (or just uncorrelated) then
π β ππ π β ππ
=
π β ππ
π β ππ
Hence
var π + π =
π β ππ
= (ππ β ππ )(ππ β ππ ) = 0
2
+
= var π + var π
π β ππ
2
[βVariances addβ]
In general, for both discrete and continuous independent (or uncorrelated) random variables
var π + π + π + β― = var π + var π + var π + β―
Example:
The mean weight of people in England is ΞΌ=72.4kg,
with standard deviation π =15kg.
What is the mean and standard deviation of the weight of
the passengers on a plane carrying 200 people?
In reality be careful - assumption
of independence unlikely to be accurate
Answer:
The total weight π =
Since means add ππ =
200
π=1 ππ
200
π=1 β©ππ βͺ
= 200 × 72.4Kg = 14480Kg
Assuming weights independent, variances also add, with π 2 = 152 Kg 2 = 225 Kg 2
200
2
ππ
=
225Kg 2 = 200 × 225 Kg 2 = 45000Kg 2
π=1
π=
45000Kg 2 β 212 Kg
Error bars
A bridge uses 100 concrete slabs, each
weighing (10 ± 0.1) tonnes
[i.e. the standard deviation of each is
0.1 tonnes]
What is the total weight in tonnes of
the concrete slabs?
1.
2.
3.
4.
5.
1000 ± 0.01
1000 ± 0.1
1000 ± 1
1000 ± 10
1000 ± 100
43%
30%
13%
7%
1
2
6%
3
4
5
Error bars
A bridge uses 100 concrete slabs,
each weighing (10 ± 0.1) tonnes
[i.e. the standard deviation of each is
0.1 tonnes]
What is the total weight in tonnes of
the concrete slabs?
Means add, so ππ‘ππ‘ = 100 × 10 = 1000 π‘πππππ
2
Variances add, with π 2 = 0.12 , so ππ‘ππ‘
= 100 × 0.12 = 1
Hence ππ‘ππ‘ = 1000 ± 1 π‘πππππ = 1000 ± 1 π‘πππππ
Note: Error grows with the square root of the number: β
But the mean of the total is β π
β fractional error decreases β 1/ π
π
Reminder:
Discrete Random Variables
=
πΆππ
Binomial distribution
π!
=
π! π β π !
A process with two possible outcomes, "success" and "failure" (or yes/no, etc.) is
called a Bernoulli trial.
e.g.
coin tossing:
quality control:
Polling:
Heads or Tails
Satisfactory or Unsatisfactory
Agree or disagree
An experiment consists of n independent Bernoulli trials and p = probability
of success for each trial. Let X = total number of successes in the n trials.
Then π π = π =
π π
π 1βπ
π
πβπ
for k = 0, 1, 2, ... , n.
This is called the Binomial distribution with parameters n and p, or B(n, p) for short.
X ~ B(n, p) stands for "X has the Binomial distribution with parameters n and p."
Situations where a Binomial might occur
1) Quality control: select n items at random; X = number found to be
satisfactory.
2) Survey of n people about products A and B; X = number preferring A.
3) Telecommunications: n messages; X = number with an invalid address.
4) Number of items with some property above a threshold; e.g. X = number
with height > A
Justification
"X = k" means k successes (each with probability p) and n-k failures (each with
probability 1-p).
Suppose for the moment all the successes come first. Assuming independence
probability = π × π × π β¦ × π × 1 β π × 1 β π × β― × (1 β π)
π successes: ππ
= ππ 1 β π
π β π failures: 1 β π
πβπ
πβπ
Every possible different ordering also has this same probability. The total number of
π
π
ways of choosing k out of the n trails to be successes is
, so there are
,
π
π
possible orderings.
Since each ordering is an exclusive possibility, by the special addition rule the
π
overall probability is ππ 1 β π πβπ added
times:
π
π π=π =
π π
π 1βπ
π
πβπ
π = 0.5
πβπ
π π=π
π π=π =
π π
π 1βπ
π
Example: If I toss a coin 100 times, what is the probability of getting exactly 50 tails?
Answer:
Let X = number tails in 100 tosses
Bernoulli trial: tail or head, π βΌ π΅ π, π = π΅(100,0.5)
100
π π = 50 = πΆππ ππ (1 β π)πβπ = πΆ50
0.550 1 β 0.5
β 0.0796
50
Example: A component has a 20% chance of being a dud. If five are selected from a
large batch, what is the probability that more than one is a dud?
Answer:
Let X = number of duds in selection of 5
Bernoulli trial: dud or not dud, π βΌ π΅(5,0.2)
P(More than one dud)
= π π > 1 = 1 β π π β€ 1 = 1 β P X = 0 β P(X = 1)
= 1 β πΆ05 0.20 1 β 0.2
5
β πΆ15 0.21 1 β 0.2
= 1 β 1 × 1 × 0.85 β 5 × 0.2 × 0.84
= 1 - 0.32768 - 0.4096 β 0.263.
4