Professional Documents
Culture Documents
ALGORITHM TEST 3
12’TH NOV’ 07
DURATION: 2 HOURS
MAXIMUM MARKS:130
NAME:
ROLL NO:
PROBABILITY SECTION
1. In Delhi the mean before-tax personal income is Rs10, 000 and the standard
deviation of the personal income is Rs4, 000. The minimum wage in Delhi is Rs
2000. The first Rs2000 of a person’s income is tax free but income tax is levied
at the rate of 30 paisa on a Rupee on all personal income above Rs 2000. What is
the mean and the standard deviation of after tax personal income (2 Marks)
2. An insurance company examines its pool of auto insurance customers and gathers
the following information:
(i) All customers insure at least one car.
(ii) 70% of the customers insure more than one car.
(iii) 20% of the customers insure a sports car.
(iv) Of those customers who insure more than one car, 15% insure a sports car.
Calculate the probability that a randomly selected customer insures exactly one
car and that car is not a sports car.
(A) 0.13
(B) 0.21
(C) 0.24
(D) 0.25
(E) 0.30 (2 marks)
2
3. Two instruments are used to measure the height, h, of a tower. The error made by
the less accurate instrument is normally distributed with mean 0 and standard
deviation 0.0056h. The error made by the more accurate instrument is normally
distributed with mean 0 and standard deviation 0.0044h.
Assuming the two measurements are independent random variables, what is the
probability that their average value is within 0.005h of the height of the tower?
(A) 0.38
(B) 0.47
(C) 0.68
(D) 0.84
(E) 0.90 (2 Marks)
4.
(4 marks)
3
1) A repair man fixes broken televisions. The repair time is exponentially distributed
with a mean of 30 minutes. Broken televisions arrive at his repair shop according
to a Poisson stream, on average 10 broken televisions per day (8 hours).
(i) What is the fraction of time that the repair man has no work to do?
(ii) How many televisions are, on average, at his repair shop?
(iii) What is the mean throughput time (waiting time plus repair time) of a
television? (3 Marks)
Solution:
(i) 3/8
(ii) 5/3
(iii) 80 minutes
2) In a gas station there is one gas pump. Cars arrive at the gas station according to a
Poisson process. The arrival rate is 20 cars per hour. Cars are served in order of
arrival. The service time (i.e. the time needed for pumping and paying) is
exponentially distributed. The mean service time is 2 minutes.
(i) Determine the distribution, mean and variance of the number of cars at the gas
station.
(ii) Determine the distribution of the sojourn time and the waiting time.
(iii) What is the fraction of cars that has to wait longer than 2 minutes? (3 Marks)
Solution:
(i) P(L = n) = 1/3*(2/3)^n; n = 0; 1; 2….and hence E(L) = 2 and (L) = 6.
(iii)2/3e-1/3=0.48
(iv) p0 = 9/19; p1=6/19; p2=4/19; hence E(L) = 14/19 =0.737 and (L)= 22/19-
(14/19)2 =0.615.
(v) E(S) = 42/19 =2.21 minutes and E(W) = 12/19 = 0.63 minutes.
4
3) Given the average arrival and service rates as 6 per hour and 8 per hour
respectively, what is the server utilization and probabilities of queue occupancy
for zero, one, two, three and four or more jobs waiting at the server.(2 Marks)
Solution:
=4/7
P(0)=1- =3/7
P(1)= =3/7*4/7=12/49
P(2)= =3/7*16/49=48/343
P(2)= =3/7*(4/7)^3=192/2301
P(4 or more)=1-(p0+p1+p2+p3)=0.10315
SAMPLING
1. We wish to find the average price of fruits (orange, apples, and mango) in a city.
For this, we adopt one of two schemes:
a. Randomly pick a fruit seller, and pick a fruit at random, check its
price. We take the average of a large number of these observations.
b. Do (a) separately for oranges, apples and mangoes (i.e. in the first step,
consider only oranges, in the second only apples, in the third only
mangoes, etc), and finally take the average of all the individual
averages. The total number of fruit prices sampled in both schemes is
the same.
Are both schemes equally good, else which is better? Why? (2+3 Marks)
Solution:
The first technique is Monte-Carlo sampling. The second one is stratified sampling.
Both the techniques are NOT equally good. The second technique is better.
Stratified sampling gives a variance that is never larger than the variance in Monte-
Carlo, but it gives smaller variance if the means of the stratified samples are
different.
In this case, we will get more accurate answers with stratified sampling if the means
of oranges, apples and mangoes are different, which they are most likely to be.
5
OPTIMIZATION SECTION
2. Solve the following linear program using the tableau method (simplex algorithm).
(5 marks) (4 marks if solved using graphical method)
Maximize 10 X1 + 5 X2
X1 is the entering basic variable since it has the most –ve coefficient.
MRT = RHS / coeff of entering basic variable.
Winner of MRT test is the equation no 2.
So S1 becomes leaving basic variable.
Since now there is no –ve coefficient in the objective function row, the RHS of row 1
is the answer, that is 30.
c. For a single commodity, the flow equations when written in matrix form
have the property that …. (2 marks)
5. On a 1 GHz laptop with 1Gb of main memory, estimate the time taken to check if
a given 100 element vector x is in the feasible region of Ax <= b, where A is a
100x 100 matrix. You should state your assumptions. What is the time if x is 1000
dimensional and A is 1000 x 1000. What is likely to happen in the latter case?
Assume IEEE-754 double precision computation (64 bits per value)
(3 + 3 + 4 = 10 marks).
Solution:
1 instruction takes – 1 nanosecond.
Number of instructions to compare Ax <= b
A * x = 2 (100 * 100 * 100) = 2 *106 instructions
A * x <= b 100 instructions
Total instructions: 2 * 106 + 100
Total time 2 milliseconds
Some Pieces of
Boundary Not
Included in Set
Solution:
Figure 1: [b, c]
Figure 2: [a, b, c]
Figure 3: [none]
Figure 4: [none]
Figure 5: [a]
Solution: c
3. Write the steps to find the singular value decomposition of the matrix
(2 marks)
I Find the eigenvalues of the matrix ATA and arrange them in descending order.
II Find the number of nonzero eigenvalues of the matrix ATA.
III Find the orthogonal eigenvectors of the matrix ATA corresponding to the
obtained eigenvalues, and arrange them in the same order to form the column-
VI Add to the matrix U the rest of m-r vectors using the Gram-Schmidt
orthogonalization process.
compute A[n–1]
compute A[n–1]x + A[n–2]
compute (A[n–1]x + A[n–2])x + A[n–3]
compute ((A[n–1]x + A[n–2])x + A[n–3])x + A[n–4]
and so on ...
Horner's algorithm:
input x
value := 0
for i := (n–1) downto 0 do value := value ∗ x + A[i]
output value
Time: O(n).
Space: O(1) space in addition to the O(n) space used by A.
10
5. While adding N terms by a computer, we add all small terms together and the
large terms together and then add the two results. Why? (2 marks)
Solution:
While adding N terms by a computer, if we add them all together, the small
terms will be swamped out by the large terms, leading to more errors. Thus, a
better way is to add all small terms together, all large terms together and then
add the two results. This will lead to smaller errors.
Solution:
If a and b are large, then the term (a2 + b2) may over flow at the intermediate
step even though √(a2 + b2) does not overflow.
│a + ib│= a 1 +
b
if b > a
a
= b +1 if a > b
a
b
7. Given the following system of linear equations, determine the value of each of the
variables using the LU decomposition method. (4 marks)
6x1 - 2x2 = 14
9x1 - x2 + x3= 21
3x1 - 7x2 + 5x3= 9
Solution:
An
f ( n) =
Bn
The value can be calculated from the double recursion (fill in the blanks)
An = an * An-2 + bn * __An-1_____
Bn = an * __Bn-2___ + bn * Bn-1 n = 1, 2, 3 ….
Write the recursion for the following continued fraction – you have to
specify the recursion for arbitrary n.
x
tan x =
x2
1−
x2
3−
x2
5−
7 − .........
(5+5 Marks)
a. Prove the following expression for Tn ( x ) :
Solution:
a. We know that
= 2 . cos(n cos-1 x) . x
= Tn(x)
Hence proved.
b.
13
If we directly calculate Tn(x) for x = 1000, then the leading term, that is
2n-1xn might overflow for a large n.
11. Name each of the following finite differencing diagrams. Briefly explain each one of
them – you should write the equations – assume that the unknown in u(x,t), which is
discretized to ujn., the PDE is ∂u/∂t = -v ∂u/∂x (6 marks)
t (time)
X (space
dimension)
14
Solution:
3. Staggered Leapfrog
12. In the SVD decomposition of a matrix A=UWVT, for two different matrices A1
and A2, we observe that
1. For A1, W is a identity matrix
2. For A2, W is a identity matrix, except for one or two very small diagonal
elements of the order of 10-15. (1+2 Marks)
a. For solving the equation Ax=b, where A is either A1 or A2, in which case
are we likely to get more accurate results?
Solution:
We are likely to get more accurate results in the case of matrix A1 as the
condition number for A1 is small. Condition number for A2 is large,
resulting in larger errors for A2.
b. For solving the equations using A-1 = V W-1 UT, what step has to be taken
to ensure accurate answers in each case (to the extent possible)
Solution:
We can change the terms of the order of 10-15 to 0 in the matrix A2.
15
A.I . QUESTIONS
14. In a 2 player game like chess/ ichess what kind of algorithms will you use to
achieve a winning position? (5)