Computing MAths
Computing MAths
Computing MAths
Structure
1.0
1.1
1.2
1.3
Introduction
Objectives
Random Variables
Discrete Random Variable
1.2.1
1.2.2
1.4
Page Nos.
5
Binomial Distribution
Poisson Distribution
1.0 INTRODUCTION
The discipline of statistics deals with the collection, analysis and interpretation of data.
Outcomes may vary even when measurements are taken under conditions that appear to
be the same. Variation is a fact of life. Proper statistical methods can help us understand
the inherent variability in the collected data, and facilitate the appropriate analysis of the
same.
Because of this variability, uncertainty is a part of many of our decisions. In medical
research, for example, interest may center on the effectiveness of a new vaccine for
AIDS; an agronomist may want to decide if an increase in yield can be attributed to a new
strain of wheat; a meteorologist may be interested in predicting whether it is going to rain
on a particular day; an environmentalist may be interested in testing whether new controls
can lead to a decrease in the pollution level; an economists interest may lie in estimating
the unemployment rate, etc. Statistics, and probabilistic foundations on which statistical
methods are based, can provide the models that may be used to make decisions in these
and many other situations involving uncertainties.
Any realistic model of a real world phenomenon must take into account the
possibilities of randomness. That is, more often that not, the quantities we are interested in
will not be predicted in advance, but rather will exhibit as inherent variation that should
be taken into account by the model. Such a model is, naturally enough, referred to as a
probability model.
In this unit we shall see what is a random variable and how it is defined for a
particular random experiment. We shall see that there are two major types of probability
distribution. We shall investigate their properties and study the different applications.
1.1 OBJECTIVES
After reading this unit, you should be able to
Note that each value in the support of X corresponds to some element (or set of elements)
in the sample space S. For example the , the value 0 corresponds to the element {a8},
while the value 1 corresponds to the set of elements { a4, a6,a7}
Therefore the sample space S, the set of all possible outcomes of this experiment
can be expressed as
S={a1, a2,,a8}
Since X is the characteristic, which denotes the number of heads out of the three tosses, it
is associated with each outcome of this experiment. Therefore, X is a function defined on
the elements of S and the possible values of X are {0,1,2,3} . The set of possible values
that X can take is called the support of X which may be denoted as . Observe, that X can
be explicitly expressed as follows;
X (a1)=3, X (a2)=X (a3)=X (a5)=2, X (a4)=X (a6)=X (a7)=1, X (a8)=0
It is interesting to observe that to each value there is always some element in sample
space or a set of element in sample spaces. For, example, the set of element in sample
spaces corresponding to the value 0 is the point {a8}; for 1, the set is {a4, a6, a7}, for 2,
the set is {a2, a3, a5} and for 3 the point is {a1}.
Therefore, we can easily make the following identification of events
corresponding to the values associated by X. Denoting the event corresponding to 0, as
{X=0}, similarly for other values, observe that
{X=0}={a8}; {X=1}={a4, a6, a7}; {X=2}={a2, a3, a5} {X=3}={a1}
If we assume that the coin is unbiased and the tosses have been performed independently,
the probabilities of all the outcomes of the sample space are equal, that is
1
P(a1)=P(a2)==P(a8) = . Therefore, using the probability law of disjoint events we can
8
easily obtain
P ({X=0}) = P ({a8}) =
1
8
3
8
3
P ({X=2}) = P ({a2, a3, a5}) = P ({a2})+P ({a3})+P ({a5}) =
8
1
P ({X=3}) = P ({a1}) =
8
P ({X=1}) = P ({a4, a6, a7}) = P ({a4})+P ({a6})+P ({a7}) =
Therefore, in this case the random variable X takes four values 0,1, 2,3 with the
probabilities 1/8,3/8,3/8,1/8 respectively. It is also important to observe that
P({X=0})+P({X=1})+P({X=2})+P({X=3})=1
It is not a coincidence, it is always true. If we add the probabilities of all possible values
of a random variable it is always one.
To sum up, we say that the random variable X, is a real valued function defined
on all the elements of a sample space of a random experiment. The random variable takes
different values, and for each value there is a probability associated with it. The sum of all
the probabilities of all the points in the support of the random variable X adds up to one.
The following figure will demonstrate the random variable X.
{0, 1, 2, 3}
Because of this representation , one can define probabilities for the set of
numbers(depending on the random variable) rather than working with arbitrary space and
this simplifies the problem considerably. Now we consider the following example.
EXAMPLE 2: You have purchased a new battery operated wristwatch and you have
inserted one new battery into it. Suppose you are interested in the following:
a) How long will it be before the first battery needs replacement ?
b) How many battery will have to be replaced during a one year period?
SOLUTION
Note that both (a) and (b) are random variables and let us discuss them one by one. In
case (a), we want to find the duration of time before the battery needs to be replaced. Note
that the variable takes values continuously along a line say from the time duration A to
time duration B. No values in between A and B are left out. In other words there is no
break in the values assumed by this random variable.
In case (b), the random variable is the number of batteries. This variable can take
values 0 or 1 or 2 etc. There is no continuity, since only non-negative integer values can
be assumed. So, the range of this variable is a discrete set of points. From this discussion
it is clear that the random variable X defined in Example 1 is also a discrete random
variable. The above examples shows that the random variables can be of two types. We
will distinguish between the following two types of random variables;
1. Discrete Random Variable , and
2. Continuous Random Variable.
Check Your Progress 1
E 1: Suppose you take a 50-question multiple-choice examination, guessing your answer,
and are interested in the number of correct answers obtained. Then
(a) What is the random variable X that you will consider for this situation?
(b) What is the set of possible values of X in this example?
(c) What does P(X=10) mean in this context?
Now in the next two sections we will describe the discrete and continuous random
variables in detail.
therefore, we have P(X= ai)=pi for I=0,1,. From the properties of a random variable and
from the probability law, we have
(a) pi 0 for all i 0
(b)
= p0 + p1 + p2 + .... = 1
i =0
From the above discussions, it follows that there exists a function p: R as follows;
if
a = ai ;
i = 0,1, 2.....
p
p(a) = i
otherwise
0
This function p is called the probability mass function (p.m.f.) of the discrete random
variable X.
The collection of the pairs {(ai, pi;I=0,1,} is called the probability distribution of X.
Another function which plays a very important role for any random variable is
known as the cumulative distribution function (c.d.f.) or simply the distribution function
of the random variable. The c.d.f. F : R[0,1] of the random variable X is defined as
F(b) = P(X b), for - < b < .
In other words, F(b) denotes the probability that the random variable X takes on a value
which will be less than or equal to b. Some important properties of the c.d.f. F (.) are
(a) F (b) is a non-decreasing function of b.
(b) lim F (b) = 1
b
Now we clarify these concepts with the same example discussed in the previous
section. Suppose X is the random variable denoting the number of heads obtained in three
independent tosses of a fair coin, then the probability mass function (p.m.f ) p is the
function, p: R, such that
1
3
1
p(0) = , p(1) = p(2) = , p(3) =
8
8
8
Therefore, p(ai) = pi 0, for all ai and
3
1 3 3 1
pi = + + + = 1
8 8 8 8
i =0
In this case the p.m.f of the random variable by the function p and the corresponding
1 3 3 1
probability distribution is the set 0, , 1, , 2, , 3, .This can also be
8 8 8 8
expressed in a tabular form as follows
TABLE 1
PROBABILITY DISTRIBUTION OF THE NUMBER OF HEADS
IN THREE INDEPENDENT TOSSES OF A FAIR COIN
Probability
1
8
3
8
3
8
1
8
0.50
0.40
Probability
0.30
0.20
0.10
0
Number of heads
Figure 2: Graphical representation of the distribution of .X
Graphically along the horizontal axis, plot the various possible values ai of a random
variable and on each value erect a vertical line with height proportional to the
corresponding probability pi.
Now let us consider the c.d.f of the random variable X. Note that if b<0, clearly
F(b)=P(X b)=0, because X takes values only {0,1,2,3}. If b=0, that is F(0)=P(X
0)=P(X=0)=1/8. If 0 b 1, then P( X b)=P(X=0)+P(0<X<b)=1/8+0=1/8. Similarly, if
b=1, F(1)= P(X 1) = P(X=0) + P(X=1)=1/8+3/8=4/8 and so on. Therefore, the c.d.f. F(.)
has the following form;
b<0
0 if
1
if 0 b < 1
8
4
F (b) =
if 1 b < 2
8
7
if 2 b < 3
b3
1 if
Example 3 A box contains twice as many red marbles as green marbles. One marble is
drawn at random from the box and is replaced ; then a second marble is drawn at random
from the box.If both marbles are green you win Rs. 50 ; if both marbles are red you loose
Rs. 10 ; and if the y are of different colour then neither you loose nor you win. Determine
the probability distribution for the amount you win or loose?
Solution Say X denote the amount you win (+) or loose (-) ; i.e X= +50 or -10
The probability that both marbles are green is 1/9 i.e. P[X=+50] =1/9
The probability that both marbles are red is 4/9 i.e. P[X=-10] =4/9
The probability that marbles are of different colours is 4/9 i.e. P[X=0] =4/9
Thus the probability distribution is given by following table
Amount(in Rs won(+) or lost(-))
+50
0
-10
Probability
1/9
4/9
4/9
1.3.1
Binomial Distribution
One very important discrete random variable (or discrete distribution) is the binomial
distribution. In this subsection, we shall discuss this random variable and its probability
distribution.
Quite often we have to deal with the experiments where there are only two
possible outcomes. For example, when a coin is tossed either a head or a tail will comes
up, a newborn is either a girl or a boy, a seed either germinates or fails to germinate. Let
us consider such an experiment. For example consider the same experiment of tossing a
coin independently three times. Note that the coin need not necessarily be a fair one, that
is P(Head) may not be equal at P(Tail)
This particular experiment has a certain characteristic. First of all it involves
repetition of three identical experiments (trials). Each trial has only two possible
outcomes: a Head or a Tail. We refer to the outcome Head as success and the outcome
Tail as failure. All trials are independent of each other. We also know that the
probability of getting a Head in a trial is p and probability of getting a tail in a trial is 1
p, that is
P(Head) = P(success) = p and P(Tail) = P(failure) = q = 1 - p
This shows that the probability of getting a success or a failure does not change from
one trial to another. If X denotes the total number of Heads, obtained in three trials, then
X is a random variable, which takes values {0,1,2,3}. Then regarding the above
experiment, we have observed the following;
(1)
(2)
(3)
(4)
Now let us try to compute the probabilities P{X = 0}, P{X = 1}, P{X = 2} and P{X =
3} in this case. Note that
P(X=0) = P(getting tails in all three trials)
= P({TTT}) = (1-p)3 = q3.
Similarly,
P(X = 1) = P(getting one Tail and two Heads in three trials)
= P({THH,HTH,HHT}) = P({THH}) + P({HTH}) + ({HHT})
= (1-p)2p+(1-p)2p +(1-p)2p = 3(1-p)2p = 3q2p.
Similarly,
P(X = 2) = (getting two Tails and one Head in three trials)
= P({HTT,THT,TTH}) = P({HTT}) + P({THT}) + ({TTH})
= (1-p)p2 + (1-p)p2 + (1-p)p2 = 3(1-p)p2=3q2p
Finally
P(X=3) = P(getting Heads in three trials)
= P({HHH}) = p3
Now observe that instead of n=3, in the above example we can easily compute the
probability for any general n. Suppose we compute P(X = r), for 0 r n, then note that
P(X = r) = C(n,r)pr(1-p)n-r = C(n,r)prqn-r,
Where C(n,r) denotes the number of ways n places can be filled with r Heads and n-r
Tails. From your school mathematics, recall that it is the number of combination of n
objects taken r at a time and it can be calculated by the following formula:
n!
C ( n, r ) =
r !( n r )!
Therefore, for r = 0,1,,n,
n!
P( X = r ) =
p r q nr ,
r !(n r )!
where
n = the number of trial made
r = the number of success
p = the probability of success in a trial
q = 1-p = the probability of a failure.
Now we define the binomial distribution formally.
Let X represents the number of successes in the set of n independent identical trials. Then
X is a discrete random variable taking values 0,1,,n. The probability of the event
P(X= r) is given by
n!
p r q n r , r=0,1,2,..,n
r !(n r )!
where n, r, p, q are same as defined before. Such a random variable X is called a binomial
random variable and its probability distribution is called the binomial distribution. A
Binomial distribution has two parameters n and p
P( X = r ) =
E1 : A farmer buys a quantity of cabbage seeds from a company that claims that
approximately 90% of the seeds will germinate if planted properly. If four seeds are
planted, what is the probability that exactly two will germinate?
1.3.2
Poisson Distribution
P( X = i) =
e i
,
i!
i = 0,1,2,3,...
Where (the Greek letter Lambda) denotes the average arrival rate per hour. For
example, suppose we know that average number of customers that arrive in that bank
during the first hour is 60 and we want to find what is the chance there will be no more
than 3 customers in the first 10 minutes. Since we know that the average arrival rate per
hour is 60 , if we denote to be the average arrival rate per 10 minutes, then
60 10
=
=10. Therefore, we can use the above formula and get
60
e 1010i
P( X = i) =
,
i = 0,1, 2,3.....
i!
But we want to find the probability that no more than 3 customers will be there in the first
ten minutes and that is
P ( X 3) = P ( X = 0) + P( X = 1) + P( X = 2) + P( X = 3)
(1)
= e 10 + e 10 10 +
e 10 10 2 e 10 10 3
+
2!
3!
(2)
(3)
What does this value 0.01038 indicate? It tells us that if the arrival rates are uniform then
there is only 1% chance that less than three customers will be there, or in other words,
there is a 99% chance that there will be more then 3 customers in the first 10 minutes.
Similarly if we want to find out the chance that there will be no more than 3
customers in the first 5 minutes, then similarly, as above we can see that in this case
60 5
= 5.
=
60
Therefore, if Y denotes the number of customers presents in the first 5 minutes, then
P (Y 3) = P(Y = 0) + P(Y = 1) + P(Y = 2) + P(Y = 3)
(4)
e 5 52 e 5 53
+
2!
3!
0.00674 +0.03369 +0.08422 +0.14037 = 0.26502
= e 5 + 5e5 +
(5)
(6)
From the above two examples it is clear that if we change the time unit (and hence the
value of ), the probabilities will change. The probability mass function (p.m.f ) given by
p (i ) = P ( X = i ) =
e i
, i = 0,1, 2,3, K
i!
represents the Poisson probability distribution. From the series expansion of e , it easily
follows that
e i
P( X = i) =
=1
i!
i =0
i =0
as it should be.
One point that should always be kept in mind is that a random variable denoting
the number of occurrences in an interval of time will follow a Poisson distribution, if the
occurrences have the following characteristics:
(a) The average occurrence rate per unit time is constant.
(b) Occurrence in an interval is independent of what has happened previously.
(c) The chance that more than one occurrence will happen at the same time is
negligible.
Now let us look at some situations where we can apply the Poisson distribution. Here is
an example
EXAMPLE 4: Calls at a particular call center occur at an average rate of 8 calls per 10
minutes. Suppose that the operator leaves his position for a 5 minute coffee break. What is
the chance that exactly one call comes in while the operator is away?
Solution: In this case the conditions (a), (b) and (c) are satisfied. Therefore if X denotes
the number of calls during a 5 minute interval, then X is a Poisson random variable with
8 5
= 4. Therefore,
=
10
P ( X = 1) =
e 4 41
= 4e 4 0.073
1!
10
That means the chance is 7.3% that the operator misses exactly one call.
Check your progress 4
E 1: If a bank receives on an average = 6 bad Cheques per day, what is the probability
that it will receive 4 bad checks on any given day
B
A
f ( x)dx = 1
f ( x)dx
Now we shall see how we can use the graph of the p.d.f. of a continuous random variable
to study real life problems
Example 5: Suppose the Director of a training program wants to conduct a programme to
upgrade the supervisory skills of the production line supervisors. Because the programme
is self-administered, supervisors require different number of hours to complete the
programme. Based on a past study, it is known that the following p.d.f. shows the
distribution of time spent by a candidate to complete the program. From the graph it is
clear that the average time
11
250
Figure 3: The p.d.f. of the time spent by a candidate to complete the program
Spent by the candidate is 250 and it is symmetrically distributed around 250. How can the
Director use this graph to find the following. What is the chance that a participant selected
at random will require
(a) more than 250 hours to complete the program
(b) less than 250 hours to complete the program
SOLUTION:Since the graph is symmetric, therefore, it is clear that area under the curve
above 250 is half. Therefore, the probability that the random variable takes values higher
1
1
than 250 is . Similarly, the random variable takes value lower than 250 is also .
2
2
Please try the following exercise now:
Now in the following subsections we will consider different continuous distributions.
1.4.1
f ( x) = B A
0
for
A< x< B
otherwise
From the p.d.f. it is clear that if A < a1 < b1 < B, A < a2 < b2 <B and b1-a1 = b2-a2, then
12
P(a1 < X < b1) = P(a2 < X < b2 ). Therefore, if the length of the intervals are same then the
corresponding probabilities will be also equal. Let us see some examples of such random
variables:
EXAMPLE 6: A train is likely to arrive at a station at any time uniformly between 6:15
am and 6:30 am. Suppose X denotes the time the train reaches, measured in minutes,
after 6:00 am.
SOLUTION In this case X is a uniform random variable takes value between (15,30).
Note that in this P(20 < X < 25) is same P(18 < x < 23) and that is equal to
25 30 23 18 1
=
=
30 15 30 15 3
Check your progress 5
E 1 An office fire drill is scheduled for a particular day, and the fire alarm is likely to ring
uniformly at any time between 10:00 am to 1:00 pm.
1.4.2
13
=3
2.5
=2
2
1.5
=1
=0 5
0.5
0
0
It is clear that f(x) is a decreasing function for all values of and f(x) tends to 0 as
x tends to . Now consider the following example.
EXAMPLE 7: suppose that the amount of time one spends in a bank to withdraw cash
from an evening counter is exponentially distributed with mean ten minutes, that is =
1/10. What is the probability that the customer will spend more than fifteen minutes in the
counter?
SOLUTION: If X represents the amount of time that the customer spend in the
counter than we need to find P(X>15). Therefore,
P (X > 15) =
=e
15
=e
3
2
0.223
15
P(X>15)= .223 represents that there is a 22.3 % chance that the customer has to
wait more than 15 minutes.
1.4.3
Normal Distribution
14
We will now state the normal distribution formally: The random variable X is said
to be normally distributed with parameters and , if the p.d.f f(x) of X is given by
f ( x) =
( x )2
2 2
Here is a real number lying between - and and is a real number lying
between 0 and .
The function f(x) may look a bit strange, but do not get bother. Just notice the
following important things. Note that it involves two parameters and , that means
corresponding to each and we get a distribution function. More over it can be seen
that for - < < and 0 < < , the function f(x) is symmetric about and is a bell
shaped one. Both and have nice interpretation. It can be easily checked that is
the average value or mean of the distribution and provides the measure of spread. The
p.d.f. of two different normal distributions are provided below.
0.8
0.7
(=1,=0.5)
0.6
0.5
0.4
0.3
(=0,=1)
0.2
0
0.1
-4
Figure 5: The p.d.f of the normal distribution for two different values of ( , ).
It is clear from the above figure that the p.d.f. is symmetric about and the shape
depends on . The spread of the distribution is more if is large.
Now let us find the P(a < X < b) for any a and b, when X follows normal
distribution with parameters and , note that,
1
2
( x )2
2 2
dx = a
1
2
z2
2
dz.
15
< Z<
. Therefore it
),
Where Z follows normal distribution with parameters 0 and 1. Although the probability
can not be calculated in a compact form, extensive tables are available for P (Z < z) for
different values of z. The table values can be used to compute P (a < X < b) for any
and .
Say we denote F(a) = P[Z<= a], the probability thet the standard normal variable Z takes
values less than or equal to a.The values of F for different values of a are calculated and
listed in table . One such table is given in the end of this unit
Note that the entries in the table are values of z for z=0.00 0.01,0.02 , ..0.09.To find the
probability that a random variable having standard normal distribution will take on a
value between a and b, we use the equation
P[a < Z < b] = F(b) F(a)
And if either a or b is negative then we can make use of the identity
F(-z) = 1 - F(z)
EXAMPLE 8 Use the table to find the following probabilities
(a) P[0.87 < Z < 1.28]
(b) P[-0.34 < Z < 0.62]
(c) P[Z >= 0.85]
(d) P[Z >= -0.65]
SOLUTION
a)P[0.87 < Z < 1.28] : Find F(1.28 from the table). In the table in the row for Z=1.2 find
the value under column 0.08 it will be 0.8997 . Similarly find F(0.87) =0.8078
so, P[0.87 < Z < 1.28] = 0.8997 0.8078 = 0.0919
b) Similarly P[-0.34 < Z < 0.62] = F(0.62) F(0.34) = F(0.62) [ 1- F(0.34)]
= 0.7324 (1 - 0.6331) = 0.3655
c) Similarly calculate P[Z > 0.85] = 1- P[Z <= 0.85] = 1-F(0.85) = 0.1977
d)P[Z > -0.65] = 1 P [ Z <= - 0.65]
= 1 F (-0.65)
= 1- F(1-F(0.65))
= 0.7422
Next we shall see that how to use the standard normal probability table to
calculate probability of any normal distribution
Standardising
Any normal random variable X, which has mean and variance 2 can be
standardized as follows.
Take a variable X, and
i)
subtract its mean (m or ) and then,
ii)
divide by its standard deviation(s or ).
16
For example, suppose, as earlier, that X is an individuals IQ score and that it has a
normal distribution with mean = 100 and standard deviation = 15. To
standardize and individuals IQ score, X, we subtract = 100 and divide the result
by = 15 to give,
X 100
Z=
15
In this way every value of X, has a corresponding value of Z. For instance, when
130 100
90 100
X = 130, Z =
= 2 and when X = 90, Z =
= 0.67 .
15
15
The distribution of standardized normal random variables
The reason for standardizing a normal random variable in this way is that a
standardized normal random variable
X
Z=
2.5
2
f(x)
1.5
f(x)
P(X<85)
1
0.5
70
85
100
115
x F
Figure 6: area under the pdf N(100,152)
Figure 5: Density function f
(x)
We cannot use normal tables directly because these give N(0,1) probabilities.
Instead, we will convert the statement X<85 into an equivalent statement which
17
X 100
because we know it has a standard
15
normal distribution.
We start with X=85. To turn X into Z we must standardize the X, but to ensure
that we preserve the meaning of the statement we must treat the other side of the
inequality in exactly the same way. (Otherwise we will end up calculating the
probability of another statement, not X<85). Standardising both sides gives,
X 100 85 100
<
.
15
15
The left hand side is now a standard normal random variable and so we can call it
Z, and we have,
85 100
Z<
15
which is
Z < 1.
So, we have established that the statement we started with, X < 85 is equivalent to
Z < 1. This means that whenever an IQ score, X is less than 85 the
corresponding standardized score, Z will be less than 1 and so the probability we
are seeking, P[X<85] is the same P[Z < 1].
P[Z < 1] is just a standard normal probability and so we can look it up in Table
1 in the usual way, which gives 0.1587. We get that P[X < 85] = 0.1587.
This process of rewriting a probability statement about X, in terms of Z, is not
difficult if you are systematically writing down what you are doing at each stage.
We would lay out the working we have just done for P[X < 85] as follows.
X has a normal distribution with mean 100 and standard deviation 15. Let us find
the probability that X is less than 85.
X 100 85 100
P[ X < 85] = P
<
15
15
= P[Z 1] = 0.1587
Let us do some problems now.
Example 9: For each of these write down the equivalent standard normal
probability.
a) The number of people who visit a historical monument in a week is
normally distributed with a mean of 10,500 and a standard deviation of
600. Consider the probability that fewer than 9000 people visit in a week.
b) The number of cheques processed by a bank each day is normally
distributed with a mean of 30,100 and a standard deviation of 2450.
Consider the probability that the bank processes more than 32,000 cheques
in a day.
Solution: Here, we want to find the standard normal probability corresponding to
the probability P[X < 9000].
18
which is
a
b
<Z<
Example 10: An individuals IQ score has a N(100, 152) distribution. Find the
probability that an individuals IQ score is between 91 and 121.
Solution: We require P[91 < X < 121]. Standardising gives
91 100 X 100 121 100
P
<
<
15
15
15
The middle term is standardized normal random variable and so we have,
21
9
P < Z < = P[0.6 < Z < 1.4] = 0.9192 0.2743 = 0.6449 .
15
15
Check your progress 6
E1 If a random variable has the standard normal distribution , find the probability that it
will take on a value
a) Less than 1.50
b) Less than 1.20
c) Greater than 1.75
E2 A filling machine is set to pour 952 ml of oil into bottles. The amount to fill are
normally distributed with a mean of 952 ml and a standard deviation of 4 ml. Use the
standard normal table to find the probability that the bottle contains oil between 952 and
956 ml ?
1.4.4
Chi-Square Distribution
In the last subsection we have discussed normal distribution. The chi-square distribution
can be obtained from the normal distribution as follows. Suppose Z1,,Zn are n
independent identically distributed normal random variables with parameters 0 and 1,
then Z12 ++ Zn2 is said to have chi-square distribution with n degrees of freedom. The
degrees of freedom here basically indicates the number of independent components which
constitute the chi-square distribution. It has received several attention because of its
appearance in the constructing analysis of variable tables, contingency tables and for
obtaining the critical values of different testing procedure. Now we formally provide the
p.d.f of a chi-square random variable with n degrees of freedom.
19
f(x) =
n/2
1
e x / 2 x ( n / 2) 1
(n / 2)
0
if x >0
otherwise
( a ) = x a 1e x dx
0
Although, the p.d.f of chi-square random variable is not a very nice looking one, do not
bother about that. Keep in mind that the shapes of density functions are always skewed. In
this case also if we want to compute P(a < X < b) for any a, b and n, explicitly it is not
possible to compute. Numerical integration is needed to compute this probability. Even
for chi-square distribution extensive tables of P(a < X < b) are available for different
values of a, b and n.
Note : We have a standard table corresponding to Chi- Square Distribution, many times
you may need to refer the values from the table. So the same is given at the end , method
of usage is similar to that discussed in Normal distribution.
SOLUTION M (t ) = E (etx ) =
1
etx x ( v 2) / 2 e x / 2 dx
2v / 2 ( v/2) 0
1
= v/2
x ( v 2) / 2 e x (1 2t ) x / 2 dx
0
2 ( v/2)
1
M (t ) = v / 2
2 ( v/2)
=
(1 2t ) v / 2
(v / 2)
2u
1 2t
( v 2) / 2
eu
2du
1 2t
u ( v / 2) 1e u du = (1 2t ) v / 2
distributed with v1 and v2 degrees of freedom respectively. Show that the moment
generating function of Z = X1 + X2 is (1 2t ) v ( v + v ) / 2
1
E2 Find the values of x2 for which the area of the right-hand tail of the x2
distribution is 0.05, if the number of degrees of freedom v is equal to (a) 15, (b)
21, (c) 50.
20
1.5 SUMMARY
In this unit we have covered following points:
a) A random variable is a variable that takes different values according to the chance
outcome
b) Types of random variables:
c) Probability distribution gives the probabilities with which the random variables
takes various values in their range
d) Discussed probability distributions :
a. Binomial Distribution : The probability of an event P[X=r] in this
distribution is given by
P(X = r) = C(n,r)pr(1-p)n-r = C(n,r)prqn-r,
b. Poisson Distribution : The probability of an event P[X=i] in this
distribution is given by
e i
,
i!
P( X = i) =
i = 0,1,2,3,...
f ( x) = B A
0
A< x< B
for
otherwise
f ( x) =
1
2
( x )2
2 2
f(x) =
n/2
1
e x / 2 x ( n / 2 ) 1
(n / 2)
0
if x >0
otherwise
( a ) = x a 1e x dx
0
21
f.
1.6 SOLUTIONS
Check Your Progress 1
E1 Case (a) is not discrete where as case (b) and (c) are discrete because in
case (a) we are taking values in an interval but in case(b) the number of
accident is finite , similarly you argue for case (c)
Check Your Progress 3
E1 This situation follows the binomial distribution with n=4 and p=90/100=9/10
The random variable X is the number of seeds that germinate. We have to
calculate the probability that exactly two of the four seedswill germinate. That is
P[X=2]. By applying Binomial formula , we get
22
/2
= (1 2t ) ( v + v ) / 2
1
using Example 9.
E2 Using the table in for Chi Square distribution we find in the column headed x2.95 the
values: (a) 25.0 corresponding to v = 15; (b) 32.7 corresponding to v = 21; (c) 67.5
corresponding to v = 50.
23
Introduction
Objectives
Uniform random number generator
Generating random variates from
arbitrary distribution
Inverse Transform
Acceptance rejection method
Summary
Solutions
2.0 INTRODUCTION
A pseudo-random number generation is the methodology to develop algorithms and programs that can be used in, probability and
statistics applications when large quantities of random digits are needed. Most of these programs produce endless strings of singledigit numbers, usually in base 10, known as the decimal system. When large samples of pseudo-random numbers are taken, each of
the 10 digits in the set {0,1,2,3,4,5,6,7,8,9} occurs with equal frequency, even though they are not evenly distributed in the sequence.
Many algorithms have been developed in an attempt to produce truly random sequences of numbers, endless strings of digits in which
it is theoretically impossible to predict the next digit in the sequence based on the digits up to a given point. But the very existence of
the algorithm, no matter how sophisticated, means that the next digit can be predicted! This has given rise to the term pseudo-random
for such machine-generated strings of digits. They are equivalent to random-number sequences for most applications, but they are not
truly random according to the rigorous definition.
A simulation that has any random aspects at all, must involve sampling or generating random variables from different probability
distributions. These distributions are often specified, that is the form of the distribution functions is explicitly known, for example it
can be exponential, gamma, normal or Poisson as discussed in Unit 1.
Random number generation has intrigued scientists for several years and a lot of efforts has been spent on the creation of
randomness on a deterministic (non-random) machine, that is to design computer algorithms that are able to produce random
sequences of integers. This is not a trivial task. Such algorithms are called generators and all generators have flaws because all of
them construct the n-th number in the sequence as a function of the (n 1) th number, initialized with a non-random seed value.
Numerous techniques have been invented over the years that measure just how random a sequence is, and most well known generator
have subjected to rigorous testing. The mathematical tools that are required to design such an algorithm are largely number theoretic
and combinatorial in nature. These tools differ drastically from those needed when we want to generate sequences of integers with
certain non-uniform distributions given that a perfect uniform random number generator is available.
The methodology of generating random numbers has a long and interesting history. The earliest methods were essentially carried out
by hand, such as casting lots, throwing dice, dealing out cards or drawing numbered balls from a well-stirred urn. Many lotteries are
still operating in this way. In the early twentieth century statisticians joined gamblers in generating random numbers and mechanized
devices were built to generate random numbers more quickly. Some time later, electric circuits based on randomly pulsating vacuum
tubes were developed that delivered random digits at rates up to 50 per second. One such random number generator machine the
Electronic Random Number Indicator Equipment (ERNIE) was used by the British General Post Office to pick the winners in the
Premium Savings Bond lottery. Another electronic device was used by the Rand Corporation to generate a table of million random
digits. In India also Indian Statistical Institute has published a book just the collection of million random numbers in the mid twentieth
century which was used for sample survey planning.
As computers and simulation became more widely used, increasing attention was paid to methods of random number
generation compatible with the way computers work. A good uniform between 0 and 1, random generator should possess certain
properties as listed below:
From a practical point of view a generator should be fast and avoid the need for a lot of storage.
We should be able to produce a given stream of random numbers from a given initial (seed) value for at least two reasons. First
this can sometimes make debugging or verification of the computer program easier or we might want to use identical random
numbers in simulating different systems in order to obtain a more precise comparison.
In this unit we will describe how to generate U (0,1) (uniform between 0 and 1, see unit 1 for the actual definition) in a
1
computer. Once we have a U (0, 1) random number, we will use that to generate several other deviates from different discrete and
continuous distributions.
2. 1 OBJECTIVES
After reading this unit, you should know
how to generate U (0, 1) random number in a computer
how to generate random deviates from any discrete distribution
how to generate random numbers from many continuous distributions, like exponential, Weibull, gamma, normal, chi-square etc.
(1)
where m, the modulus, a, the multiplier, c, the increment and Z0, the seed or the initial value, are all non-negative integers. Those who
are not familiar with the definition of modules, note that for non-negative integers, x, y and z, x = y (mod z) means x is the remainder
when the integer y is divided the integer z. For example if y = 10 and z = 3, then x = 1, or if y = 10 and z = 2, then x = 0. Therefore,
from (1) it is clear that to obtain Zi, first divide aZi 1 + c by m and Zi is the corresponding remainder of this division. It is clear that 1
Zi m 1 and to obtain the desired random numbers Ui, for i = 1, 2. On [0, 1], we let Ui =
Zi
. The choice of the non-negative
m
integers, a, c and m are the most crucial steps, and they come from the theoretical considerations. In addition to non-negatively, they
also should satisfy 0 < m, a < m and c < m. Moreover, the initial value Z0 < m.
Immediately, two objections could be raised against LCGs. The first objection is one which is common to all random number
generators, namely the Zis defined by (1) are not really random. It can be easily seen that for i = 1, 2,.,
c(a i 1)
Zi = a i Z 0 +
(mod m),
1
a
so that every Zi is completely determined by m, a, c and Z0. However, by careful choice of these four parameters the aim is to induce a
behavior in the Zis that makes the corresponding Uis appear to be independent identically distributed U (0, 1) random variates when
subjected to variety to statistical tests.
The second objection to LCGs might be that the Uis can take on only the rational numbers 0,
1 2
( m 1)
,
, .,
; in fact
m m
m
the Uis might take only a fraction of these values, depending on the specifications of the four parameters. Therefore, there is no
possibility of getting a value of Ui between, say
0 .1
0 .9
0 .8
and
, whereas this should occur with probability
> 0. We will see later
m
m
m
that the modulus m is usually chosen to be very large, say 109 or more, so that the points in [0, 1] where Uis can fall are very dense.
This provides an accurate approximation to the true continuous U (0, 1) distribution, sufficient for most purposes.
Let us consider the following example:
Example 1 : Consider the LCG defined by m = 16, a = 5, c = 3 and Z0 = 7. The following table gives Zi and Ui (up to three decimal
places) for i = 1, ., 19. Note that Z17 = Z1 = 6, Z18 = Z2 = 1 and so on. Therefore, from i = 17, the sequence repeats itself. Naturally
we do not seriously suggest anybody to use this generator. The main reason here m is too small. This we are presenting just for
illustrative purpose.
Table 1
The LCG Zi = (5Z i 1 + 3) (mod 16) with Z0 = 7
2i
Zi
Ui
Zi
Ui
Zi
Ui
Zi
Ui
0
1
2
3
4
7
6
1
8
11
0.375
0.063
0.500
0.688
5
6
7
8
9
10
5
12
15
14
0.625
0.313
0.750
0.938
0.875
10
11
12
13
14
9
0
3
2
13
0.563
0.000
0.188
0.125
0.813
15
16
17
18
19
4
7
6
1
8
0.250
0.438
0.375
0.063
0.500
Note that the repeating behaviour of LCG is inevitable. By the definition of Zi, whenever it takes on a value it had taken previously,
from that point onward the sequence will repeat itself endlessly. The length of a cycle is called the period of a generator. For LCG, Zi
depends only on the previous value Zi 1 and since 0 Zi m 1, it is clear that the period is at most m. If it m, the LCG is said to
have full period. Clearly, if a generator is full period, any choice of the initial seed Z0 from {0,,m-1} will produce the entire cycle in
some order.
Since for large scale simulation projects may require hundreds of thousands of random numbers, it is desirable to have LCGs
with long periods. Moreover, it is desirable to have full period LCGs, because then it is assured to have every integer between 0 and m
1 exactly once in every cycle. Thus it is very important to know how to choose a, m and c so that the corresponding LCG will have
full period. We should also keep in mind that obtaining full period is just one desirable property for a good LCG. It should also have
good statistical properties, such as apparent independence, computational and storage efficiency and reproducibility. Reproducibility
is simple. For reproducibility, we must only remember that the initial seed Z0 initiates the generator with this value again to obtain the
same sequence of Ui exactly. Some of the standard LCGs with different values of a, m and c are presented below. These LCG have
been observed to perform very well in several machines and passed the standard statistical tests also.
Generator 1: a = 16807,
Generator 2: a = 1664525,
m = 231 1,
m = 232,
c = 0.
c = 1664525.
Fortunately today, most of the simulation packages and even simple scientific calculators have reliable U (0 1,) generator available.
Check your progress 1
E1 What do you mean by Pseudo random number generation? What is the practical advantage of the concept of random number
generation? Do you know any algorithm which works in designing the software for Random number generation?
1
0.9
U1
0.8
0.7
0.6
0.5
F(x)
0.4
0.3
0.2
0.1
-2
-1
X1
Note that when F is a strictly increasing function, F1 (U) will be always defined, since 0 U 1 and the range of F is [0, 1]. Figure 1
illustrates the algorithm graphically. According to the figure it is clear that the uniform random variable U1 results the random
variable X1 with the distribution function F. To show that the value X1 returned by the above algorithm has the desired distribution
function F, note that
P (X1 x) = P (F1 (U1 ) x) = P (U1 F (x)) = F (x).
The first equality follows from the definition of X1, the second equality follows because F is invertible and the third equality follows
because U1 follows U (0,1).
EXAMPLE 2: Let X have the Weibull distribution with the following probability density function:
e x x 1 if
f(x) =
0
if
x>0
-1
Find F
x<0
SOLUTION Here and both are known constants and both of them are strictly greater than 0.
Therefore, X has the distribution function
1 e x
0
F (x) =
if
if
x>0
x0
Therefore, to compute F1 (u), let us equate u = F (x) and we solve for x to obtain
F
(u) = [
{ In (1 u)} ]
Therefore to generate X from a Weibull distribution with = 2 and = 1, generate U from U (0, 1) and then set
X = [{ In (1 u)}]
1
2
1
2
F (x) = P (X x) =
p( x ),
xi x
Step 2: Determine the smallest positive integer I such that U F (x1) and return
X = xI . The following figure 2 illustrates the method. In that case we generate X=x4
Now to show that the discrete inverse transform method is valid, we need to show that P (X = xi) = p (xi) for all i = 1, we get X = x1, if
and only if U F (x1) = p (x1), since xis are in the increasing order and U follows U (0,1). For i 2, the algorithm sets X = xi if and
only if F (xi 1) < U F (xi), since the i chosen by the algorithm is the smallest positive integer such that U F (xi). Further, since U
follows U (0,1) and 0 F (xi 1) < F (xi) 1,
P (X = xi) = P {F (xi 1 < U F (xi)} = F (xi) F (xi 1) = p (xi).
Now consider the following example.
F(x)
x1
x2
x
x3
x4
X
x5
1
1
1
, P (X = 2) = , P (X = 4) = . Generate a random sample from X?
2
4
4
SOLUTION
0
1
2
F (x) = 3
4
1
if
x <1
if
1 x < 2
if
2 x<4
if
x4
The distribution function is X is presented in the Figure 3. If we want to generate a random sample from X, first generate a random
variable U from U (0, 1). If U
F(x)
1
1
3
, then assign X = 1. If < U , then assign X = 2, otherwise assign X = 4.
2
2
4
0.8
0.6
E1 Let X have the exponential distribution with mean 1. The distribution function is
1 e x if x 0
Find F-1
if x < 0
0
(x)
E2 Consider another discrete random variable which may take infinitely many values. Suppose the random variable X has the
following probability mass function.
1
, i = 1, 2, 3, . Generate a random sample from X?
2i
P (X = i) = pi =
2. 5 ACCEPTANCE-REJECTION METHOD
In the last subsection we have discussed the inverse transformation method to generate random number from different non-uniform
distributions. Note that apparently, the inverse transformation method seems to be the most general method to generate random
deviate from any distribution function functions. In fact it can be used provided the distribution function can be written in an explicit
form, or more precisely the inverse of the distribution function can be computed analytically. For example, in case of exponential,
Weibull, Cauchy distributions the distribution function and also their inverses can be constructed analytically. Unfortunately that is
not the case in general. Suppose the random variable X follows gamma with the shape and scale parameters as and respectively.
Then the density function of X, say
fx (x | , ), is
1 x
x e
if
f (x | , ) =
0
if
x>0
x0
not be calculated explicitly. Exactly the same problem arises if X is a normal random variable. Suppose X is a normal random variable
with mean and variance 2, then the probability density function of X, say f (x | , ) is
f (x | , ) =
1
2
( x )2
2 2
In this case also the distribution function can not be computed analytically and similarly its inverse also. Therefore in these cases we
can not apply the inverse transformation method to generate the corresponding random deviates. The acceptance-rejection method can
be used quite effectively to generate these random deviates. It can be described as follows.
Suppose we have a density function f (x) and we want to generate a random deviate from the density function f (x). The
distribution function of f (x) can not be expressed in explicit form. The acceptance-rejection method requires that we specify a
function g (x) that majorizes the function f (x), that is, f (x) g (x) for all x. Naturally, g (x) will not be a density function always, since
c=
g ( x)dx f ( x) = 1,
1
g ( x) is clearly a density function provided c < . Now for any given f (x), we choose the function g (x),
c
such that c < and it is possible to generate random deviate from g (x) by a inverse transformation method. Then we can generate the
random deviate X from f (x) as follows:
ALGORITHM
Step 3: If U
f (Y )
, X = Y, otherwise go back to Step 1 and try again.
g (Y )
Note that the algorithm is looping back to Step 1 until we generate a pair (Y, U) pairs in Steps 1 and 2 for which U
f (Y )
, when we
g (Y )
accept the value Y for X. Theoretically it can be shown that the random deviate X generated by the above algorithm has indeed the
probability density function f (x). Since it is not very easy to prove the result we do not provide it.
EXAMPLE 4: Consider the following density function
60 x 3 (1 x) 2 if
f (x) =
0
0 x 1
otherwise
0
if
x<0
1
if
x >1
0.8
0.6
0.4
x)
0.2
0
0
0.2
0.4
0.6
0.8
2.5
1.5
)
0.5
0
7
From the distribution function F (x) is provided in figure 4 .It is clear that the distribution function F (x) is a strictly increasing
function of x in [0, 1]. Therefore F1 (x) exists, but unfortunately to find F1 (x) we need to solve a six degree polynomial, which can
not be obtained analytically. We need to solve numerically only. Therefore, we can not generate random deviate from the density
function f (x) using the inversion method. But we will be able to generate random deviate from f (x) using the acceptance-rejection
method.
First let us look at the graph of the density function f (x). It is presented in the Figure 5. From the Figure 5 it is clear that f (x) is an
unimodal function with a unique maximum. The maximum can be easily obtained by the standard differential calculus, that is by
setting
df ( x)
= 0. We see that the maximum of f (x) occurs at x = 0.6 and the maximum value at 0.6, that is f (0.6) = 2.0736.
dx
Therefore, if we define
2.0736 if
0
g (x) =
0 < x <1
otherwise.
then clearly f (x) g (x) for all x. Now to calculate h (x), first we need to calculate c. Since,
1
c=
2.0736
= 1 if 0 < x < 1
h (x) = c
0
otherwise.
It is immediate that h (x) is just the U(0,1) density function. Now the algorithm takes the following form.
60Y 3 (1 Y ) 2
then return with X = Y,otherwise go back to Step 1.
2.0736
1 1 x
x
e
f (x) = ( )
if
x>0
otherwise
2. 6 SUMMARY
In this unit we have discussed the meaning of pseudo random number generation and along with that we have described
uniform random number generator and arbitrary random number generator. Under Uniform random number generator case
we have emphasized on LCG (Linear Congruential Generator) and some objections related to LCG. Actually LCGs
provides an algorithm how to generate uniform random number between (0,1). It can be simply described as follows.
A sequence of integers Z1, Z2, is defined by the recursive formula
8
(1)
where m, the modulus, a, the multiplier, c, the increment and Z0, the seed or the initial value, are all non-negative integers
Then we have discussed the concept , algorithm and application of Inverse transforms for random number generation .
In brief Suppose we want to generate a random variate X that has a continuous and strictly increasing distribution function
F, when 0 < F (x) < 1, i.e., whenever x1 < x2 then F (x1) < F (x2). Let F1 denote the inverse of the function F. Then an
algorithm for generating a random variate of X having distribution function F is as follow .
ALGORITHM
Step 1: Generate U1 from U1 (0,1)
Step 2: Return X1 = F1 (U1).
The inverse-transform method can be used also when the random variable X is discrete.
In this case the distribution function is
p( x ),
F (x) = P (X x) =
xi x
Step 2: Determine the smallest positive integer I such that U F (x1) and return
X = xI . The following figure 2 illustrates the method. In that case we generate X=x4
Note:
the inverse transformation method to generate random number from different non-uniform distributions. Note that apparently,
the inverse transformation method seems to be the most general method to generate random deviate from any distribution
function functions. In fact it can be used provided the distribution function can be written in an explicit form
Finally we had discussed the Acceptance Rejection method of random number generation, this method is quite important because
,when the distribution function can not be computed analytically and similarly its inverse also. Then in such cases we can not apply
the inverse transformation method to generate the corresponding random deviates. The acceptance-rejection method can be used quite
effectively to generate these random deviates.
In brief ,Suppose we have a density function f (x) and we want to generate a random deviate from the density function f (x). The
distribution function of f (x) can not be expressed in explicit form. The acceptance-rejection method requires that we specify a
function g (x) that majorizes the function f (x), that is, f (x) g (x) for all x. Naturally, g (x) will not be a density function always, since
c=
g ( x)dx f ( x) = 1,
1
g ( x) is clearly a density function provided c < . Now for any given f (x), we choose the function g (x),
c
such that c < and it is possible to generate random deviate from g (x) by a inverse transformation method. Then we can generate the
random deviate X from f (x) as follows:
ALGORITHM
Step 1: Generate Y having density function g (x).
Step 2: Generate U from U (0,1) which is independent of Y.
Step 3: If U
f (Y )
, X = Y, otherwise go back to Step 1 and try again.
g (Y )
Note that the algorithm is looping back to Step 1 until we generate a pair (Y, U) pairs in Steps 1 and 2 for which U
f (Y )
, when we
g (Y )
accept the value Y for X. Theoretically it can be shown that the random deviate X generated by the above algorithm has indeed the
probability density function f (x). Since it is not very easy to prove the result we do not provide it.
9
2. 7 SOLUTIONS
Check your progress 1
E1 A pseudo-random number generation is the methodology to develop algorithms and programs that can be used in,
probability and statistics applications when large quantities of random digits are needed. Most of these programs produce
endless strings of single-digit numbers, usually in base 10, known as the decimal system. When large samples of pseudorandom numbers are taken, each of the 10 digits in the set {0,1,2,3,4,5,6,7,8,9} occurs with equal frequency, even though
they are not evenly distributed in the sequence.
Many algorithms have been developed in an attempt to produce truly random sequences of numbers, endless strings of
digits in which it is theoretically impossible to predict the next digit in the sequence based on the digits up to a given point.
But the very existence of the algorithm, no matter how sophisticated, means that the next digit can be predicted! This has
given rise to the term pseudo-random for such machine-generated strings of digits. They are equivalent to random-number
sequences for most applications, but they are not truly random according to the rigorous definition.
There are several methods available to generate uniform random numbers. But currently the most popular one is the linear
congruential generator (LCG). Most of the existing softwares today use this LCGs proposed by Lehmer in the early 50s.
Check your progress 2
E2 Note that
2
i =1
= 1, therefore pi denotes the probability mass function of a discrete random variable. The
F (x) = m 1
i =1 2i
if
x <1
if
m x < m + 1,
where m is any positive integer. Now to generate a random deviate from the random variable X, first draw a random
m 1
m
0
1
1
1
sample U from U (0, 1), since 0 U 1, there exits a positive integer m such that i U < i , where i = 0,
i =1 2
i =1 2
i =1 2
then X = m,
Check your progress 3
E1 Our problem is to generate random deviate from f (x) for a given 0 < < 1. Note that we can not use the acceptancerejection method in this case. It is easily observed if we take
0
if
x0
x 1
if 0 < x < 1
g (x) =
( )
e x
if
x > 1,
( )
then f (x) g (x) for all x. In this case
c=
10
g (x) =
x 1
0 ( ) dx +
1
1 (e + a )
ex
dx =
.
( )
( ) ae
1
g (x) is
c
0
if
x0
1
x
h (x) =
if 0 x 1
b
e x
if
x > 1,
b
e+a
where b =
. The distribution function H (x) corresponds to the density function h (x) is
e
Therefore, h (x) =
x
b
H (x) = h (y) dy =
x
0
1 e
b
Which can be easily inverted as
if
0 x 1
if
x > 1,
(
bu
)
if u
b
H 1 (u) =
In b(1 u ) if u > 1
Therefore, it is possible to generate random deviate from the density function h (x) using the simple inversion method.
Generation of a random deviate Y from the density function h (x) can be performed as follows. First generate U1 from U (0,
1
1
b (1 U1 )
1), if U1 we set Y = (bU1) , in this case Y 1. Otherwise Y = In
and in this case Y > 1. Also note that
b
Y
if 0 Y 1
f (Y ) e
= 1
g (Y ) Y
if
Y >1
Now the algorithm to generate random deviate from a gamma density function with the shape parameter , for 0 < < 1
takes the following form:
Step 1: Generate U1 from U (0,1) and let P = bU1. If P > 1, go to Step 3 otherwise proceed to Step 2.
Step 3: Let Y = In
(b P )
11
Regression Analysis
Introduction
Objectives
Simple Linear Regression
3.2.1
3.2.2
3.2.3
3.3
3.0
Non-Linear Regression
3.3.1
3.4
3.5
Page Nos
Summary
Solutions
INTRODUCTION
In many problems there are two or more variables that are inherently related and it may be
necessary to explore the nature of their relationship. Regression analysis is a statistical
technique for modeling and investigating the relationship between two or more variables.
For example in a chemical process suppose that the yield of the product is related to the
process operating temperature. Regression analysis can be used to build a model that
expresses yield as a function of temperature. This model can be used to predict yield at a
given temperature level. It can also be used for process optimization or process control
purposes.
In general, suppose that there is a single dependent variable or response variable y and
that is related to k independent or regressor variables say x1,..,xk. The response
variable y is a random variable and the regressor variables x1,,xk are measured with
negligible error. The relationship between y and x1,..xk is characterized by a
mathematical model and it is known as the regression model. It is also known as the
regression of y on x1,..,xk. This regression model is fitted to a set of data. In many
situations the experimenter knows the exact form of the functional relationship
between y and x1, ..., xk, say (x1, ..., xk), except for a set of unknown parameters.
When the functional form is unknown, it has to be approximated on the basis of
past experience or from the existing information. Because of its tractability, a
polynomial function is popular in the literature.
In this unit we will be mainly discussing the linear regression model and when k = 1, that
is only one regressor variables. We will be discussing in details how to estimate the
regression line and how it can be used for prediction purposes from a given set of data.
We will also discuss briefly how we can estimate the function , if it is not linear.
3.1 OBJECTIVES
After reading this unit, you should be able to
Decide how two variables are related.
Measure the strength of the linear relationship between two variables.
Calculate a regression line that allows to predict the value of one of the variable if
1
y = 0 + 1 x +
(1)
Yield (y)
80
100
120
140
160
180
200
220
Temperature (x)
Figure 1: Scatter diagram of yield versus temperature
where is a random variable with mean 0 and variance 2. The is known as the error
component and it is assumed to be small. If the error was absent then it was a perfect
relation between the variables y and x which may not be very practical. Let us look at the
following example.
Example 1: A chemical engineer is investigating the effect of process operating
temperature on product yield. The study results in the following data.
Temperature C (x)
Yield,%(y)
Regression Analysis
100 110 120 130 140 150 160 170 180 190
45
51
54
61 66 70
74
78
85
89
The scatter diagram between the temperature and the yield is presented in the Figure 1
above. From the Figure 1 it is clear that there is a linear relationship between yield and
temperature but clearly it is not perfect. For example we can not write the relationship
between y and x as follows
y = 0 + 1 x
Clearly the presence of the error is needed. Moreover the error is a random variable
because it is not fixed and it varies from one temperature to another. It may also vary
when two observations are taken at the same temperature. If there was a perfect
linear relationship between y and x we would have required just two points to find the
relationship. Since the relationship is not perfectly linear it is usually required much more
than two data points to find their relationship. Our main objective is to find the
relationship between them from the existing information (data points). Since it is assumed
that the relationship between x and y is linear therefore the relationship can be expressed
by the equation (1) and finding the relationship basically boils down finding the unknown
constants 0 and 1 from the observations.
Let us discuss this concept of linear regression by one more illustration/collection of data
described in the table 1 given below. This table encloses the data of 25 samples of
cement, for each sample we have a pair of observation (x,y) where x is percentage of SO3,
a chemical and y is the setting time in minutes. These two components are strongly
related; it is the percentage of SO3 which influences the setting time of any cement
sample, the recorded observations are given in table 1 below.
Percentage of SO3
x
1.84
1.91
1.90
1.66
1.48
1.26
1.21
1.32
2.11
0.94
2.25
0.96
1.71
2.35
1.64
1.19
1.56
1.53
Setting Time
Y (in minutes)
190
192
210
194
170
160
143
164
200
136
206
138
185
210
178
170
160
160
19
20
21
22
23
24
25
Total
Sum of
Squares
0.96
1.7
1.68
1.28
1.35
1.49
1.78
39.04
140
168
152
160
116
145
170
4217
64.446
726539
From the table 1, you see that setting time y increases as percentage of SO3
increases. Whenever you find this type of increasing (or decreasing) trend in a
table , same will be reflected in the scatter diagram ,and it indicates that there is a
linear relationship between x and y. By drawing the scatter diagram you can
observe that the relationship is not perfect in the sense that a straight line cannot
be drawn through all the points in the scatter diagram.
Nevertheless, we may approximate it with some linear equation. What formula
shall we use? Suppose, we use the formula y = 90 + 50x to predict y based on x.
To examine how good this formula is, we need to compare the actual values of y
with the corresponding predicted values. When x = 0.96, the predicted y is equal
to 138(= 90 + 50 x 0.96). Let (xi, yi) denote the values of (x, y) for the ith sample.
From Table-1, notice that x12=x19=0.96, whereas y12 = 138 and y19 = 140.
Let $y = 90 + 50 xi . That is, $yi is the predicted value of y (then using y = 90 + 50x
for the ith sample. Since, x12=x19=0.96, both $y12 and $y19 are equal to 138. Thus the
difference e$i = yi $yi , the error in prediction, also called residual is observed to
be e$ 12 = 0 and e$ 19 = 2. The formula we have considered above, y = 90 + 50x, is
called a simple linear regression equation , we will study these terms in detail in
our successive sections.
3.2.1
Suppose that we have n pairs of observations, say (x1 , y1),.(xn , yn). It is assumed that
the observed yi and xi satisfy a linear relation as given in the model (1). These data can be
used to estimate the unknown parameters 0 and 1 . The method we are going to use is
known as the method of least squares, that is, we will estimate 0 and 1 so that the sum
of squares of the deviations from the observations to the regression line is minimum. We
will try to explain it first using a graphical method in Figure 2. For illustrative purposes
we are just taking 5 data points (x, y) = (0.5, 57), (0.75, 64), (1.00, 59), (1.25, 68),
(1.50,74). The estimated regression line can be obtained as follows. For any line we have
calculated the sum of the differences (vertical distances) squares between the y value and
the value, which is obtained using that particular line. Now the estimated regression line
is that line for which the sum of these differences squares is minimum.
90
Regression Analysis
85
80
Observed point
Difference
65
60
Estimated point
55
0
0.5
1.5
Figure 2 Differences between y values and the estimated values using regression line
Matematically the sum of squares of the deviations of the observations from the
regression line is given by
n
L=
i2 =
i =1
(y
i
1 xi ) 2
i =1
The least squares estimators of 0 and 1 , are 0 and 1 which can be obtained by
solving the following two linear equations.
n
L
= 2 ( yi 0 1 xi ) = 0
0
i =1
n
L
= 2 ( y i 0 1 xi ) = 0
1
i =1
xi =
i =1
(2)
i =1
i =1
i =1
0 xi + 1 xi2
y x
(3)
i i
i =1
0 = y 1 x
1 =
n
yx
i =1 i i
1
n
x2
i =1 i
(4)
( yi )( x )
1
( xi )
n
n
n
i =1 i
i =1
(5)
i =1
where y =
y and x = x
i
i =1
i =1
(6)
y
x
x
bxy = Regression coeff of y on x = r
y
r x + y
= tan 1
y
( x x)
x
x
( y y)
y
Example 1 (contd.) Now we will compute the estimates of 0 and 1 for the data points
given in Example 1. In this case it is observed
10
n = 10,
i =1
xi = 1450,
10
yi = 673,
i =1
x = 145,
y = 67.3
10
xi2 = 218,500,
i =1
10
10
x y
i i
i =1
Therefore,
1 =
Regression Analysis
= 101,570
i =1
and
(7)
The best fitted line along with the data points are plotted in the Figure 3. Note that the
best fitted line can be used effectively for prediction purposes also. For example suppose
we want to know the expected yield when the temperature is 170C, for which the data is
not available. We can use the (7) for this purpose as follows.
y = 2.739 + 0.483 170 = 79.371 .
Therefore, the best fitted line shows that the expected yield at 170C is 79.371.
100
90
80
70
Yield (y)
60
50
40
80
100
120
140
160
180
200
220
Temperature (x)
Figure 3: Data points and the best fitted regression line passing through these points
Soon in this section only, we will discuss the technique consisted of few steps; which can
be used to fit a line in best way, such that the error is minimum. In crux we will study the
technique to determine the best equation, that can fit a line in the data such that the error
is minimum. But before that lets see one more example.
7
Example 2: A survey was conducted to relate the time required to deliver a proper
presentation on a topic , to the performance of the student with the scores he/she receives.
The following Table shows the matched data:
Table 2
Hours (x)
Score (y)
0.5
57
0.75
64
1.00
59
1.25
68
1.50
74
1.75
76
2.00
79
2.25
83
2.50
85
2.75
86
3.00
88
3.25
89
3.50
90
3.75
94
4.00
96
(1) Find the regression equation that will predict a students score if we know how many
hours the student studied.
(2) If a student had studied 0.85 hours, what is the students predicted score?
Solution. We will arrange the data in the form of a chart to enable us to perform the
computations easily.
x
0.5
0.75
1.00
1.25
1.50
1.75
2.00
2.25
2.50
2.75
3.00
3.25
3.50
3.75
4.00
33.75
y
57
64
59
68
74
76
79
83
85
86
88
89
90
94
96
1188
Table 3
x2
0.25
0.56
1.00
1.56
2.25
3.06
4.00
5.06
6.25
7.56
9.00
10.56
12.25
14.06
16.00
93.44
xy
28.5
48.0
59.0
85.0
111.0
133.0
158.0
186.75
212.5
236.5
246.0
289.25
315.0
352.50
384.0
2863
Regression Analysis
y = 54.772 + 10.857 x
Now the predicted score when x = 0.85, is
Score (y)
70
65
Predicted line
60
55
50
Hours (x)
Figure 4: Hours studied and the corresponding score with the best fitted regression line passing
through these points
Thus the predicted score of the student who had studied 0.85 hours is approximately
64.00.
We have plotted the individual scores and the hours studied with the best fitted prediction
line in the Figure 4. It shows the hours studied by the student and the corresponding score
follows a linear pattern and the predicted line can be used quite effectively to predict the
score of a student if we know how many hours the student had studied.
Now, its the time to discuss the technique for determining the best equation, i.e., the
equation which fits the line in a way that the overall error is minimized.
From above illustrations and examples you might have noticed that different
equations give us different residuals. What will be the best equation? Obviously,
$i are small.
the choice will be that equation for which es
$i zero
This means that whatever straight line we use, it is not possible to make all es
, where e$i = yi $yi (the difference). However, we would expect that the errors are
positive in some cases and negative in the other cases so that, on the whole, their
sum is close to zero. So, our job is to find out the best values of 0 and 1 in the
formula y = 0 + 1 x + e ( s.t. e 0) . Let us see how we do this.
Sxx = x 2i n x
(8)
i =1
xi
is the mean of the observed
n
Sxy = xi yi n x y
(9)
i =1
where xis and yis are the x-values and y-values given by the data and x and
y are their means.
Sxy
3) Calculate
= 1 say. That is
Sxx
Sxy
1 =
(10)
Sxx
4) Find y 1 x = 0 , say.
Let us now compute these values of the data in Table 1: Data on SO3 and Setting
Time, we get
x = 1.5616, y = 168.68, Sxx = 3.4811, and Sxy = 191.2328.
Substituting these values in (10) and (11), we get
Sxy
1 =
= 54.943 and 0 = 168.68 54.943 x 1.5616 = 82.88
(11)
Sxx
Therefore, the best linear prediction formula is given by
y = 82.88 + 54.943x.
After drawing this line on the scatter diagram, you can find that this straight lines
is close to more points, and hence it is the best linear prediction.
Example 3: A hosiery mill wants to estimate how its monthly costs are related to its
monthly output rate. For that the firm collects a data regarding its costs and output for a
sample of nine months as given in the following table.
Table 4
10
Output (tons)
1
2
4
8
6
5
8
9
7
2
3
4
7
6
5
8
8
6
Regression Analysis
(a) Find the scatter diagram for the data given above.
(b) Find the regression equation when the monthly output is the dependent variable (x)
and monthly cost is the independent variable (y).
(c) Use this regression line to predict the firms monthly cost if they decide to produce 4
tons per month.
(d) Use this regression line to predict the firms monthly cost if they decide to produce 9
tons per month.
Solution
a) Suppose that xi denote the output for the ith month and yi denote the cost
for the ith month. Then we can plot the graph for the pair (xi, yi) of the
values given in Table . Then we get the scatter diagram as shown in Figure
below.
C
O
S
T
(T
H
O
U
S
A
N
D
S
OF
10
9
8
D 3
O
L 2
L
A 1
R)
0
1
4
5
6
7
OUTPUT (TONS)
Figure 5: Scatter Diagram
10
b) Now to find the least square regression line, we first calculate the sums Sxx
and Sxy from Eqn.(8) and (9).
n
Sxx = x 2i nx
i =1
i =1
y
i = 49
n
9
2
x
i
=
340
y=
y = 303
and x y = 319
2
i i
1 = i =n1
x 2 nx
1
i =1
9 x 319 50 x 49
9 x 340 502
421
=
= 0.752
560
Correspondingly, we get
49
50
0 = (0.752) x
9
9
= 1.266
Therefore, the best linear regression line is
y = 1.266 + (0.752)x
c) If the firms decides to produce 4 tons per month, then one can predict that
its cost would be
1.266 + (0.752) x 4 = 4.274
Since the costs are measured in thousands of dollars, this means that the total
costs would be expected to be $4,274.
d) If the firms decides to produce 9 tons per month, then one can predict that
its cost would be 1.266 + (0.752) x 9=8.034
Since the costs are measured in thousands of dollars, this means that the
total costs would be expected to be $8034.
Check your progress 1
what were
12
E2 Since humidity influences evaporation, the solvent balance of water reducible paints
during sprayout is affected by humidity. A controlled study is conducted to examine the
relationship between humidity (X) and the extent of evaporation (Y) is given below in
table 5. Knowledge of this relationship will be useful in that it will allow the painter to
adjust his or her spray gun setting to account for humidity. Estimate the simple linear
regression line and predict the extent of solvent evaporation (i.e loss of solvent ,by
weight)when the relative humidity is 50%
Regression Analysis
Table 5
Observation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(x)
Relative
humidity,
(%)
35.3
29.7
30.8
58.8
61.4
71.3
74.4
76.7
70.7
57.5
46.4
28.9
28.1
39.1
46.8
48.5
59.3
70.0
70.0
74.4
72.1
58.1
44.6
33.4
28.6
(y)
Solvent
Evaporation,
(%) wt
11.0
11.1
12.5
8.4
9.3
8.7
6.4
8.5
7.8
9.1
8.2
12.2
11.9
9.6
10.9
9.6
10.1
8.1
6.8
8.9
7.7
8.5
8.9
10.4
11.1
We have seen in the previous subsection that the regression line provides estimates of the
dependent variable for a given value of the independent variable. The regression line is
called the best fitted line in the sense of minimizing the sum of squared errors. The best
fitted line shows the relationship between the independent (x) and dependent (y) variables
better than any other line. Naturally the question arises How good is our best fitted
line?. We want a measure of this goodness of fit. More precisely we want to have a
numerical value which measures this goodness of fit.
For developing a measure of goodness of fit, we first examine the variation in y. Let us
first try the variation in the response y. Since y depends on x, if we change x, then y also
changes. In other words, a part of variation in ys is accounted by the variation in xs.
13
Actually, we can mathematically show that the total variation in ys can be split up as
follows:
n
Syy =
S 2 xy
( yi y ) 2 =
S xx
i =1
( y y ) ,
i
(12)
i =1
where
Sxx =
( xi x) 2 ; Sxy =
i =1
( x x)( y y )
i
i =1
S 2 xy
S xx S yy
n
i =1
( yi yi ) 2
S yy
Since the quantities on the right hand side are both non-negative, none of them can exceed
one. Also if one of them is closer to zero the other one has to be closer to one. Thus if we
denote
S xy
R=
S xx S yy
then
S 2 xy
R =
S xx S yy
n
i =1
( yi yi ) 2
S yy
( y y )
= 0 or
=0
or
yi = yi
for all i.
i =1
( y y )
i
i =1
that y decreases as x increase and when R is positive y increases when x increases. Thus R
gives a measure of strength of the relationship between the variables x and y.
Now let us compute the value of R for Example 1. For calculating the numerical value of
R, the following formula can be used;
R=
S xy
S xx S yy
n
i =1
n
i =1
( xi x)( yi y )
( xi x ) 2
n
i =1
( yi y ) 2
n
x2
i =1 i
n
xy
i =1 i i
nx 2
nx y
n
y2
i =1 i
ny 2
R=
218,500 10 145
and
=
2
47225 10 67.3
3985
8250 1932.1
= 0.9981
R2 = 0.9963.
Therefore, it is clear from the value of R or from R2 that both of them are very close to
one. From the figure also it is clear that the predicted line fits the data very well.
14
Moreover R is positive means, there is a positive relation between the temperature and
yield. As the temperature increases the yield also increases.
Regression Analysis
Now the natural question is how large this R or R2 will be to say that the fit is very good.
There is a formal statistical test based on F-distribution which can be used to test whether
R2 is significantly large or not. We are not going into that details. But as a thumb rule we
can say that if R2 is greater that 0.9, the fit is very good, if it is between 0.6 to 0.8, the fit
is moderate and if it is less than 0.5 it is not good.
Check your progress 2
E1) For the data given in the table below compute R and R2
Table 6: $yi and e$i For Some Selected i
Sample
12
21
15
1
24
No. (i)
xi
0.96
1.28
1.65
1.84
2.35
yi
138
160
178
190
210
$yi
138
e$i
15
9
9
9
9
ei
9
9
9
9
9
9 9 9
9
9
9
9
9
9
yi
Figure 6 Pattern of the residual plot; satisfactory.
The Figure 6 indicates that the residuals are behaving in satisfactory manner and the
model assumptions can be assumed to be correct. The Figures 7 9 given below indicate
unsatisfactory behaviour of the residuals. The Figure 7 clearly indicates that the variances
are gradually increasing. Similarly the Figure 8 indicates that the variances are not
constant. If the residuals plot is like the Figure 9, then it seem the model order is not
correct, that means, the first order model is not the correct assumption. We should look
for higher order models.
*
*
*
ei
*
*
*
* *
*
* *
*
*
*
*
yi
*
*
16
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
ei
*
*
yi
Regression Analysis
*
*
*
*
*
ei
*
*
*
*
*
*
*
yi
Figure 9 Patent of the residual plot; indicates the
model order is not correct.
Example 4: Now we provide the residual plots of the data given in Example 1. We have
plotted yi vs. ei. It is provided in the Figure 10. From the Figure 10, it is quite clear that
the residuals plot is quite satisfactory and apparently all the model assumptions are
satisfied in Figure 10 here.
1.5
1
0.5
ei
-0.5
-1
0
45
50
55
60
65
70
75
80
85
90
yi
Figure10 Pattern of the residual plot; satisfactory.
17
E1 What is the utility of residual plots? what is the disadvantage of residual plots?
Protein
(gm)
0.844
0.908
0.932
0.936
0.925
0.908
0.881
0.850
Time
(min)
80
90
100
110
120
130
140
150
Table 7
Protein
(gm)
0.818
0.784
0.751
0.718
0.685
0.685
0.628
0.603
Time
(min)
160
170
180
190
200
210
220
230
Protein
(gm)
0.580
0.558
0.538
0.522
0.506
0.490
0.478
0.467
Time
(min)
240
250
260
270
280
290
300
310
Protein
(gm)
0.457
0.448
0.438
0.431
0.424
0.420
0.414
0.411
(13)
18
Regression Analysis
[ y f ( x , )] ,
2
(14)
i =1
with respect to the unknown parameters. The idea is same as before, that is we try to find
that particular value of for which the sum of squares of the distance between the points
yi and f ( xi , ) is minimum. Unfortunately in this case the minimum can not be performed
as easily as before. We need to adopt some numerical technique to minimize the function
Q( ) . This minimization can be performed iteratively and one technique that can be used
to accomplish this is the Gauss-Newton method.
1
0.9
0.8
Protein
0.7
0.6
0.5
0.4
0
50
100
150
200
250
300
350
Time
You have already learned about the Gauss-Newton method in details before, we just give
a brief description for your convenience. We use the following notations below:
= (1 ,....., p ),
( k ) = (1( k ) ,........, p( k ) )
(15)
Expand the function f ( x, ) using a Taylor series expansion about the starting point (0)
and using the only the first order expansion, we get:
f ( xi , ) f ( xi , (0) ) + vi1 (1 1(0) ) + ..... + vip ( p p(0) )
where
vij =
f ( xi , )
j
for
= ( 0)
j = 1,.........., p.
19
Let ( ) = ( f ( x1 , ),....., f ( xn , ))' and y = y = ( y1 ,...... yn ) ' then in the matrix notation
we can write (15)
( ) ( (0) ) + V (0) ( (0) ),
where V (0) is the p derivative matrix with elements vij. Therefore, to compute the first
estimates beyond the starting value is to compute
b0 = [V (0)'V (0) ]1[ y ( (0) )]
and then solve for the new estimate (1) as
(1) = b0 + (0) .
This procedure is repeated then with ( 0 ) is replaced by (1) and V (0) by V (1) and this
produces a new set of estimates. This iterative procedure continues until convergence is
achieved. Naturally these computations can not performed by hands, we need calculators
or computers to perform these computations.
Example 5 (Contd). In this case it is observed (theoretically) that the following model (16)
can be used to explain the relationship the time and yield generated yi where
yt = 0 + 1e 1t + 2 e 2t + t .
(12)
Note that as we have mentioned for the general non-linear regression model, in this case
also the form of the non-linear function namely 0 + 1e 1t + e 2t is known, but the
parameters of the model, that is, = ( 0 ,1 , 2 , 1 , 2 ) is unknown. Given the data as
provided in Example 5, we want to estimate the unknown parameters.
We use the following initial guess 0 = 0.5,1 = 1.5, 2 = 1.0, 1 = 0.01, 2 = 0.02,
and finally using the Gauss-Newton algorithm we obtain the estimates of the parameters
as follows:
0 = 0.375,
1 = 1.936
2 = 1.465 ,
0 = 0.013
1 = 0.022
We have plotted the points and also the best fitted regression line, namely
y = 0.375 + 1.936e 0.013t 1.465e 0.013t
(17)
1
0.9
Fitted line
0.8
Protein
0.7
0.6
0.5
0.4
0
50
100
150
200
250
300
350
Figure 12 Time vs Protein generated in an experiment and the best fitted curve
20
Time
Regression Analysis
in the Figure 12. The Figure 12 indicates that the fitted regression curve provides a very
good relationship between the time and protein generated in that experiment. As before
the prediction curve, that is, the curve (17) can be used easily for prediction purposes also.
For example suppose we want to estimate the expected protein generation at the time 115
minutes after the experiment, then using (17), we obtain
y = 0.375 + 1.936e 0.013115 1.465e 0.013115 = 0.698.
Therefore, at the 115 minutes the expected protein generation is 0.698 gms.
Some points we should remember about the non-linear regression model is that we have
to know the functional form of the relationship, but the parameters involved are unknown.
Usually the functional forms are obtained from the physical nature of the process and they
are available. If they are completely unknown it is difficult to use the non-linear
regression model. In that case we need to try with some guess models but they are not
very easy and they are not pursued here. Another important issue is the choice of the
guess value of the iterative process. This is also a difficult problem. Usually from the
prior experimental results we may have to try some trial and error method to find the
initial guess values.
Check your progress 4
E1 Data on the amount of heat generated by friction were obtained by Count Rumford in
1798. A bore was fitted into a stationery cylinder and pressed against the bottom by
means of a screw. The bore was turned by a team of horses for 30 minutes and Rumford
measured the temperature at small in intervals of time. They are provided in the Table
below:
Time
(min)
4
5
7
12
14
16
20
Table 8
Temperature Time
(F)
(min)
126
24
125
28
123
31
120
34
119
37.5
118
41
116
Temperature
(F)
115
114
113
112
111
110
(1) Plot the time versus temperature and convince yourself that the linear regression
model is not the correct model in this case.
(2) A model based on Newtons law of cooling was proposed as
f (t , ) = 60 + 70e t
Using an initial guess of (0) = 0.01, find the least squares estimate of .
(3) Based on the fitted least squares regression line find the expected temperature at the
time 15th minute after starting the experiment.
21
3.4 SUMMARY
In this unit you have seen :
that regression analysis is an important technique, which can be used to verify the
results of any experiment.
that by knowing the technique of regression you have an edge to analyse the
results in an organized way. Further this analysis is smoothened by application of
the concepts like least square estimation, goodness to fit and residual analysis.
that many times the data obtained by conducting an experiment does not follow
the linear relation. So, to handle such aspects we have also discussed the concept
of non linear regression, under we have emphasized least square estimation
technique.
Non-Linear Regression
3.5 SOLUTIONS
Check you r progress 1
E 1:
(1) Since both the regression lines pass through the point ( x , y ), we have
8 x 10 y + 66 = 0
40 x 18 y 214 = 0
Solving we get,
x = 13
y = 17.
8
66
18
214
and x =
x +
y +
10
10
40
40
(4)
8 4
=
10 5
18 9
bxy = regression coeff of x on y =
=
40 20
4 9
9
Hence, r2 = bxy. byx =
=
5 20
25
3
= 0.6
So r =
5
Regression Analysis
y
x
4
3
y
=
x
5
5
3
y=4
Remarks (i) had we taken 8x 10y + 66 = 0 as regression equation of x on y and
40x 18y = 214, as regression equation of y on x.
10
40
Then
bxy =
and
byx =
8
18
10
40
or
r2
=
bxy byx =
x
= 2.78
8
18
so
r = 1.66
Which is wrong as r lies between 1.
E2
Observation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(x)
Relative
humidity,
(%)
35.3
29.7
30.8
58.8
61.4
71.3
74.4
76.7
70.7
57.5
46.4
28.9
28.1
39.1
46.8
48.5
59.3
70.0
(y)
Solvent
Evaporation,
(%) wt
11.0
11.1
12.5
8.4
9.3
8.7
6.4
8.5
7.8
9.1
8.2
12.2
11.9
9.6
10.9
9.6
10.1
8.1
23
19
20
21
22
23
24
25
70.0
74.4
72.1
58.1
44.6
33.4
28.6
6.8
8.9
7.7
8.5
8.9
10.4
11.1
n = 25
x2 = 76.308.53
y = 235.70
xy = 11824.44
To estimate the simple linear regression line, we estimate the slope 1 and
intercept 0. these estimates are
n xy [( x)( y )]
=1 => $ 1 = b1 =
n x 2 ( x)2
25(11,824.44) [(1314.90)(235.70)]
=
25(76,308.53) (1314.90) 2
= .08
0. => $ 0 = b0 = y b1 x
= 9.43 ( .08) (52.60) = 13.64
S
O
L
V
E
N
T
14
13
12
11
E 10
V
A 9
P
O 8
R
A 7
T
I 6
O
N 5
(% wt)
24
10
20
30
40
50
60
70
RELATIVE HUMIDITY (%)
80
90
100
Regression Analysis
E1 R =
S xy
S xx S yy
So, R2 = 0.9033
Check your progress 3
E1 Residual plots are helpful in spotting potential problems. How ever theyare not always
easy to interpret. Residual patterns are hard to spot with small data set except in extreme
cases, residual plots are most useful with fairly large collection of data.
25
Table 2: The critical values of chi-square distribution. The areas given across the top are
the areas to the right of the critical value. To look up an area on the left, subtract it from
one, and then look it up (i.e., 0.05 on the left is 0.95 on the right).
df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
0.995 0.99
0.975 0.95
0.90
0.001
0.004
0.016
0.010
0.020
0.051 0.103
0.211
0.072
0.115
0.216 0.352
0.584
0.207
0.297
0.484 0.711
1.064
0.412
0.554
0.831 1.145
1.610
0.676
0.872
1.237 1.635
2.204
0.989
1.239
1.690 2.167
2.833
1.344
1.646
2.180 2.733
3.490
1.735
2.088
2.700 3.325
4.168
2.156
2.558
3.247 3.940
4.865
2.603
3.053
3.816 4.575
5.578
3.074
3.571
4.404 5.226
6.304
3.565
4.107
5.009 5.892
7.042
4.075
4.660
5.629 6.571
7.790
4.601
5.229
6.262 7.261
8.547
5.142
5.812
6.908 7.962
9.312
5.597
6.408
7.564 8.672
10.085
6.265
7.015
8.231 9.390
10.865
6.844
7.633
8.907 10.117 11.651
7.434
8.260
9.591 10.851 12.443
8.034
8.897
10.283 11.591 13.240
8.643
9.542
10.982 12.338 14.041
9.260
10.196 11.689 13.091 14.848
9.886
10.856 12.401 13.848 15.659
10.520 11.524 13.120 14.611 16.473
0.10
2.706
4.605
6.251
7.779
9.236
10.645
12.017
13.362
14.684
15.987
17.275
18.549
19.812
21.064
22.307
23.542
24.769
25.989
27.204
28.412
29.615
30.813
32.007
33.196
34.382
0.05
3.841
5.991
7.815
9.488
11.070
12.592
14.067
15.507
16.919
18.307
19.675
21.026
22.362
23.685
24.996
26.296
27.587
28.869
30.144
31.410
32.671
33.924
35.172
36.415
37.652
0.025
5.024
7.378
9.348
11.143
12.833
14.449
16.013
17.535
19.023
20.483
21.920
23.337
24.736
26.119
27.488
28.845
30.191
31.526
32.852
34.17
35.479
36.781
38.076
39.364
40.646
0.01
6.635
9.210
11.345
13.277
15.086
16.812
18.475
20.090
21.666
23.209
24.725
26.217
27.688
29.141
30.578
32.000
33.409
34.805
36.19
37.566
38.932
40.289
41.638
42.980
44.341
0.005
7.879
10.597
12.838
14.860
16.750
18.548
20.278
21.955
23.589
25.188
26.757
28.300
29.819
31.319
32.801
34.267
35.718
37.156
38.582
39.997
41.401
42.796
44.181
45.559
46.928