Documente Academic
Documente Profesional
Documente Cultură
Lecture Probability
Faculty of Science
1 / 38
Random Variables
Definition
A random variable is a numerical measure of the outcome from a
probability experiment, so its value is determined by chance.
Random variables are denoted using letters such as X.
Definition
A discrete random variable is a random variable that has values
that has either a finite number of possible values or a countable
number of possible values.
Definition
A continuous random variable is a random variable that has an
infinite number of possible values that is not countable.
2 / 38
Examples
3 / 38
Examples
3 / 38
Examples
3 / 38
Examples
3 / 38
Examples
3 / 38
Probability distribution
4 / 38
Discrete Probability Distributions
Definition
Rules for a discrete probability distribution
Let P(x) denote the probability that the random variable X equals
x; then
P
1 P(x) = 1
2 0 ≤ P(x) ≤ 1
5 / 38
examples
Determine whether the distribution is discrete probability
distribution.
Table
P (a) not a discrete distribution it does not meet
P(x) = 1
Table
P (b) is a discrete distribution It meets the condition
P(x) = 1
6 / 38
Probability Histogram
7 / 38
Example
x P(x)
0 0.30
1 0.15
2 ?
3 0.20
4 0.15
5 0.05
8 / 38
Example
x P(x)
0 0.30
1 0.15
2 ?
3 0.20
4 0.15
5 0.05
8 / 38
Histograms
9 / 38
Mean and Standard deviation
Definition
The mean of a Discrete Randomvariable is given by the formula
X
µx = [x · P(x)]
10 / 38
Variance and standard deviation
Definition
The variance of a discrete random variable is given by
X
σx2 = [(x − µx )2 · P(x)] (1)
X
= [x 2 · P(x)] − µ2 x (2)
where x is the value of the random variable µx is the mean of the
random variable, and P(x) is the probability of observing the
random variable x.
11 / 38
Standard deviation
Definition
p
Standard deviation is the quare root of the variance σx2
12 / 38
example
Example
Find the mean, variance, and standard deviation of the discrete
random variable x.
0 0.073 0 ∗ (0.73) = 0
1 0.117 1 ∗ (0.117) = 0.117
2 0.258 2 ∗ (0.258) = 0.516
3 0.322 3 ∗ (0.322) = 0.966
4 0.230 4 ∗ (0.230 = 0.920
P
µx = [x · P(x)] = 2.5189
13 / 38
How to do this using software package R
1 Open R
2 x < −c(0, 1, 2, 3, 4)
3 f < −c(0.075, 0.117, 0.258, 0.322, 0.230)
4 mu < −sum(x ∗ f )
5 mu
14 / 38
Expected Value
Definition
The expected value of a discrete random variable X is defined as
m
X
E (X ) ≡ hX i = pi xi .
i=1
15 / 38
Expected Value Example
X -1 3 5
P(X) 0.3 0.2 0.5
16 / 38
Expected value R code
x<-c(-1,3,5)
> f<-c(0.3,0.2,0.5)
> ex<-sum(f*x)
> ex
[1] 2.8
>
17 / 38
Binomial distribution
Definition
An experiment is said to be a binomial experiment if
1 If the experiment is performed a fixed number of times. Each
repetition is called a trial.
2 The trials are independent. This means the outcome of one
trial will not effect the outcome of the other trials.
3 For each trial, there are two mutually exclusive outcomes:
success or failure.
4 The probability of success is the same for each trial of the
experiment
18 / 38
examples
19 / 38
examples
19 / 38
examples
19 / 38
Notations used
20 / 38
Binomial Probability Distribution Function
x = 0, 1, . . . n
where p is the probability of success
21 / 38
example
Hockey cards, chosen at random from a set of 20, are given away
inside cereal boxes. Stan needs one more card to complete his set
so he buys five boxes of cereal. What is the probability that he will
complete his set?
1 Number of trials n= 5
2 number of success x=1
1 1
3 Probability of success = ,p =
20 20
19 19
4 Probability of failure = ,q =
20 20
Probability of success =
5 1 19
× ( )1 × ( )4 = 0.20
1 20 20
22 / 38
example
seven coins are tossed. What is the probability of four tails and 3
heads.
1 number of trials n = 7
2 Number of success x = 4
1
3 probability of success p =
2
1
4 probability of failure p =
2
7 1 4 1
× ( ) × ( )3 = 0.273
4 2 2
23 / 38
example
A true or false test 12 questions. Suppose you guess all 12. What
is the probability of exactly seven correct answers
1 n = 12
2 number of successn = 7
1
3 probability of success =
2
1
4 probability of failure =
2
12 1 1
× ( )7 × ( )5 = 0.0.193
7 2 2
24 / 38
example
25 / 38
Example
A family has nine children. What is the probability that there is at
least one girl?
1 trials n = 9
2 success x = 0
1
3 probability of success p =
2
1
4 probability of failure q =
2
Probability of zero girls =
9 1 0 1 9
× × = 0.00195
0 2 2
The probability of atleast one girl = 1− probability of zero girls
1 − 0.00195 = 0.998
26 / 38
Normal Distribution
x − µ2
1 −
f (x) = √ e 2σ
σ 2π
The function happends to be symmetrical, and bell shaped
27 / 38
Normal distribution examples
28 / 38
Create a normal curve using R
plot(x,y)
29 / 38
Normal Curve
30 / 38
Creating a Normal Distribution Curve
x<-seq(-3,3,length=200)
> y = dnorm(x,mean=0,sd=1)
> plot(x,y)
31 / 38
Normal distribution
32 / 38
Normal plot
if we want to connect the plots use
plot(x,y,type="l")
33 / 38
Finding the area under the normal curve
x=seq(-3,3,length=200)
y=dnorm(x,mean=0,sd=1)
plot(x,y,type="l")
x=seq(-3,0,length=100)
y=dnorm(x,mean=0,sd=1)
polygon(c(-3,x,0),c(0,y,0),col="red")
34 / 38
Normal Curves
35 / 38
Finding the area under the normal curve
pnorm(1,mean=0,sd=1)
[1] 0.8413447
36 / 38
z score
What is a Z score
A measure of an observations distance from the mean.
The distance is measured in standard deviation units.
If a z-score is zero, its on the mean.
If a z-score is positive, its above the mean.
If a z-score is negative, its below the mean.
If a z-score is 1, its 1 SD above the mean.
If a z-score is −2, its 2 SDs below the mean
37 / 38
Computing a z score
Definition
X −µ
z=
σ
OR
X −X
z=
SD
38 / 38