Quantitative Interview questions and answers

Daniel Duffy

C++ author, trainer
Compute exp(5) to 2 decimal places using only pen(cil) and paper. You may assume exp(1) is known.
 

amraj

Member
What do you mean by 'difference'?
Valid point. There could be many differences. I have listed just one obvious one above. In fact, any answer of the x2_i=x1_i + c_i s.t mean of the vector c is 0.1 would state be an example of a difference.
Simply stating "One has a mean =2.5, and the other has a mean of 2.6" - another difference =D
 

Daniel Duffy

C++ author, trainer
Valid point. There could be many differences. I have listed just one obvious one above. In fact, any answer of the x2_i=x1_i + c_i s.t mean of the vector c is 0.1 would state be an example of a difference.
Simply stating "One has a mean =2.5, and the other has a mean of 2.6" - another difference =D
The very fact that an interviewee has questions on the questions can be a plus point. It's not always the destination but also the journey;)
 

Rohan Jain

New Member
Partitioned Mathematicians





Solution:

This solution is an incomplete one. I will not provide a closed-form formula in terms of n and k. Instead I will come up with a recursive relation. The closed-form formula will be presented in another post.

Let f(n,k) denote the number of ways to place n mathematicians in k rooms such that in each room there will be at least one mathematician.

Now partition the set of all these ways according to the number of mathematicians in room k. So, imagine j mathematicians are placed in room k, where 0<j<n-k. There are C(n,j) ways to choose j mathematicians out of the n that can be placed in room k, where C(n,j)=n!/[j! (n-j)!]. For each choice of j mathematicians placed in room k, the remaining (n-j) mathematicians will be placed in rooms 1 through (k-1) in f(n-j,k-1) ways. So, for each choice of j where 0<j<n-k, there are a total of C(n,j)* f(n-j,k-1) ways in which j mathematicians are placed in room k and (n-j) are placed in rooms 1 through (k-1), with all the rooms non-empty. So, all we have to do now is to sum up all these ways to get the grand total, the answer to the question:

f(n,k)=sigma{ C(n,j)* f(n-j,k-1) as j runs from 1 through n-(k-1)}.

The preceding can be simplified to

f(n,k)=sigma{ C(n,j)* f(j,k-1) as j runs from k-1 through n-1}, which can be written as

f(n,k)=sigma{ C(n,j)* f(j,k-1) as j runs from 0 through n-1}.

Note: f(n,k)=0 and C(n,k)=0 if n<k, where k>0. Some other initial values need to be determined.





Hi quantyst,

I came up with another recursion to solve this problem.

f(n,k) = k*f(n-1,k) + k*f(n-1,k-1)

Explanation:
Suppose we know the value of f(n-1,k) and f(n-1,k-1), now the nth person can be put in one of the k rooms where n-1 guys are already there (k*f(n-1,k)) plus nth person can be put in a single room which is not already occupied by the n-1 guys.(k*f(n-1,k-1))

The basic difference in our solutions is: you are looking for the ways to fill the kth room, I'm looking the ways so the nth mathematician can be added
 

Rohan Jain

New Member
Hello everyone,
Can anyone help me figure out the correct answer to the following problem.

There are n mathematicians numbered 1 through n, who want to be placed in k rooms numbered 1 through k, such that in each room, there will be at least one mathematician. In how many ways can you do this?

Thanks in a
 

Kevin Ramlal

New Member
Hello everyone,
Can anyone help me figure out the correct answer to the following problem.

There are n mathematicians numbered 1 through n, who want to be placed in k rooms numbered 1 through k, such that in each room, there will be at least one mathematician. In how many ways can you do this?

Thanks in a
k!S(n,k)

Where S(n,k) is the Stirling number of the second kind.

Stirling numbers of the second kind - Wikipedia, the free encyclopedia
http://www.math.uvic.ca/faculty/gmacgill/guide/Stirlings.pdf

Stirling numbers is the number of ways to separate n distinguishable objects into k non empty indistinguishable boxes.

Since in your case the boxes are also distinguishable you need to multiply by k!
 

Rohan Jain

New Member
k!S(n,k)

Where S(n,k) is the Stirling number of the second kind.

Stirling numbers of the second kind - Wikipedia, the free encyclopedia
http://www.math.uvic.ca/faculty/gmacgill/guide/Stirlings.pdf

Stirling numbers is the number of ways to separate n distinguishable objects into k non empty indistinguishable boxes.

Since in your case the boxes are also distinguishable you need to multiply by k!
Thanks for the reply..
I came up with the following recursion:
f(n,k) = k*f(n-1,k) + k*f(n-1,k-1)
And I think its same as k!*(stirling no. of 2nd kind)
 

Rohan Jain

New Member
Another interesting question i've found online..

You are taking out candies one by one from a jar that has 10 red candies, 20 blue candies, and 30 green candies in it. What is the probability that there are at least 1 blue candy and 1 green candy left in the jar when you have taken out all the red candies? (Candies of same color are indistinguishable!)

P.S. It doesn't require much calculation
 

Quant Crack

New Member
Another interesting question i've found online..

You are taking out candies one by one from a jar that has 10 red candies, 20 blue candies, and 30 green candies in it. What is the probability that there are at least 1 blue candy and 1 green candy left in the jar when you have taken out all the red candies? (Candies of same color are indistinguishable!)

P.S. It doesn't require much calculation
Answer is 7/12.
X_r, X_b and X_g are the last positions of red, blue and green candies respectively, when taken out of jar. Required Event (E) is : X_r < X_g < X<b (call it A) and X_r < X_b < X_g (call it B)
Using conditional probability:
P(E) = P(A)*P(E|A) + P(B)*P(E|B)
P(A) = ( 59!/ (10!*19!*30!) )/ (60!/ (10!*20!*30!) ) = 1/3
P(B) = ( 59!/ (10!*20!*29!) )/ (60!/ (10!*20!*30!) ) = 1/2
P(E|A) = P(X_r < X_g) = P( getting X_r < X_b out of forty candies (10 Reds and 30 Green), = (39!/(10!29!)) / (40! / (10!30!)) = 3/4
similarly P(E|B) = 2/3

So, P(E) = (1/3)*(3/4) + (1/2)*(2/3) = 7/12
 

Rohan Jain

New Member
Answer is 7/12.
X_r, X_b and X_g are the last positions of red, blue and green candies respectively, when taken out of jar. Required Event (E) is : X_r < X_g < X<b (call it A) and X_r < X_b < X_g (call it B)
Using conditional probability:
P(E) = P(A)*P(E|A) + P(B)*P(E|B)
P(A) = ( 59!/ (10!*19!*30!) )/ (60!/ (10!*20!*30!) ) = 1/3
P(B) = ( 59!/ (10!*20!*29!) )/ (60!/ (10!*20!*30!) ) = 1/2
P(E|A) = P(X_r < X_g) = P( getting X_r < X_b out of forty candies (10 Reds and 30 Green), = (39!/(10!29!)) / (40! / (10!30!)) = 3/4
similarly P(E|B) = 2/3

So, P(E) = (1/3)*(3/4) + (1/2)*(2/3) = 7/12
Correct..!!
But u made a slight mistake in defining events A and B, i.e. A: X_b>X_r and X_b>X_g and similarly for B

But to answer this in one line:
= 20/(20+30+10) * 30/(30+10) + 30/(20+30+10) * 20/(20+10)

Explanation:
Its because prob. that blue candy is drawn at the end = prob. that its drawn at the beginning = 20/60 = 1/3
Once you've drawn blue candy at the end, ignore all the blue candies and apply the same argument for the remaining red and green candies
 

Quant Crack

New Member
Correct..!!
But u made a slight mistake in defining events A and B, i.e. A: X_b>X_r and X_b>X_g and similarly for B

But to answer this in one line:
= 20/(20+30+10) * 30/(30+10) + 30/(20+30+10) * 20/(20+10)

Explanation:
Its because prob. that blue candy is drawn at the end = prob. that its drawn at the beginning = 20/60 = 1/3
Once you've drawn blue candy at the end, ignore all the blue candies and apply the same argument for the remaining red and green candies
In event A. Fix the last ball to 'Blue'. Now you have to permute 59 balls where 10 are of same kind(Red), 30 are of another kind (Green) and 19 are of another kind (Blue). so total number of permutations = 59!/(10!19!30!). Same goes for B. I hope this clarifies your confusion.
 

Rohan Jain

New Member
In event A. Fix the last ball to 'Blue'. Now you have to permute 59 balls where 10 are of same kind(Red), 30 are of another kind (Green) and 19 are of another kind (Blue). so total number of permutations = 59!/(10!19!30!). Same goes for B. I hope this clarifies your confusion.
Perfect!
 

Rohan Jain

New Member
Here are 2 interesting questions:
Q1) You have in front of you, a barrel of N ping pong balls, each labeled with a unique number. You pull a ball from the barrel, make a note of the label, and then put the ball back. After pulling K balls from the barrel, what is the probability that you've seen all of the balls? What happens when k=N and K>N. Consider these 2 cases separately.
P.S. A recursive answer is also acceptable

Q2) A confused-looking man on the street asks if you want to play a game of chance. The rules are simple: He flips his coin, and if it lands on heads, you get $1. If it lands on tails, you get nothing. His coin, however, is very strangely shaped - it's bent all over, and you have no idea if it's even remotely fair. The man flips the coin once, and it lands on heads.
What is the maximum price you should be willing to pay to play this game now? You can assume that you know nothing about the true probability of heads for the coin before you saw the first head, and that probability is not going to change over time.
 

Jakelaker

Member
Here are 2 interesting questions:
Q1) You have in front of you, a barrel of N ping pong balls, each labeled with a unique number. You pull a ball from the barrel, make a note of the label, and then put the ball back. After pulling K balls from the barrel, what is the probability that you've seen all of the balls? What happens when k=N and K>N. Consider these 2 cases separately.
P.S. A recursive answer is also acceptable

Q2) A confused-looking man on the street asks if you want to play a game of chance. The rules are simple: He flips his coin, and if it lands on heads, you get $1. If it lands on tails, you get nothing. His coin, however, is very strangely shaped - it's bent all over, and you have no idea if it's even remotely fair. The man flips the coin once, and it lands on heads.
What is the maximum price you should be willing to pay to play this game now? You can assume that you know nothing about the true probability of heads for the coin before you saw the first head, and that probability is not going to change over time.
Q1) If K = N, then Pr(seeing all balls) = N!/(N^N).

If K > N, then Pr(seeing all balls) = Pr(see all balls using n picks) + Pr(see all balls using n+1 picks) + ... + Pr(see all balls using k) picks = N!/(N^N) + ...

Seems too hard so let's do the complement.

Pr(not seeing all balls) = Pr(seeing only 1 ball) + Pr(seeing only 2 balls) + ... + Pr(seeing only k-1 balls).
= C(N,1)/(N^K) + C(N,2)/(N^K) + ... + C(N,K-1)/(N^K)
= (2^n - 2)/(N^K).

Therefore, Pr(seeing all balls) = 1 - (2^n - 2)/(N^K).

Q2) Have no idea...
 

Rohan Jain

New Member
Q1) If K = N, then Pr(seeing all balls) = N!/(N^N).

If K > N, then Pr(seeing all balls) = Pr(see all balls using n picks) + Pr(see all balls using n+1 picks) + ... + Pr(see all balls using k) picks = N!/(N^N) + ...

Seems too hard so let's do the complement.

Pr(not seeing all balls) = Pr(seeing only 1 ball) + Pr(seeing only 2 balls) + ... + Pr(seeing only k-1 balls).
= C(N,1)/(N^K) + C(N,2)/(N^K) + ... + C(N,K-1)/(N^K)
= (2^n - 2)/(N^K).

Therefore, Pr(seeing all balls) = 1 - (2^n - 2)/(N^K).

Q2) Have no idea...

Hi Jakelaker, I dont think your solution is correct for K>N (your approach is correct however)
First of all, C(N,1) + C(N,2)+ ... + C(N,K-1) is not equal to (2^n - 2)
(it is true only for K=N)

Second, I think its a typo.. C(N,K) is not defined for K>N. And you forgot about the arrangements we can have if we choose r balls (r<N)

Have a look at my solution

Solution:
Approach 1:
Pr(not seeing all balls) = sum from r = 1 to N-1 (C(N,r) r^k)/N^k)
ans = 1 - Pr(not seeing all balls)

Approach 2:
p(n,k) is prob. of getting n different balls in k pulls

p(n,k) = 1/k p(n-1,k-1) + p(n,k-1)
ans = p(N,K)
 

Rabi

New Member
...
Here's where the assumptions begin to come in. For one thing, we assume that the roll and the decision to lie are independent; under this assumption, the numerator is easy:

[TEX]P(rolls 6, reports 6) = P(rolls 6, tells the truth) = \frac{1}{6}*\frac{1}{4} = \frac{1}{24}[/TEX]
Firstly, apologies for replying to an ancient thread--however it is a curious result reported above.

Why is this not [TEX]P_{report6}(rolls 6)=\frac{\frac{1}{6}\frac{3}{4}}{\frac{1}{6}\frac{3}{4} + \frac{5}{6}\frac{1}{4}}[/TEX]

In my reading of the question, I calculate the final probability to be 3/8, which is slightly higher than the 1/4 chance Bob calculated.
 
Last edited:

Skander

Active Member
C++ Student
Hi there, I hope you are all doing well:)
I have a quick conceptual question,
Why is the volatility used as a parameter in pricing options ie. BS formula and not in the Formula for pricing futures contracts? any ideas?
 

gver

Member
Hi there, I hope you are all doing well:)
I have a quick conceptual question,
Why is the volatility used as a parameter in pricing options ie. BS formula and not in the Formula for pricing futures contracts? any ideas?
A long shot answer perhaps ..

you pay zero for the future (always that price) but something for an option .. and this something depends on your expected payoff, which is directly proportional to your vol levels .. however, for a future, you just solve for the fwd price/strike and pay zero .. its independent of your underlying vol ..

perhaps someone can provide a much more sane explanation :)
 

Skander

Active Member
C++ Student
A long shot answer perhaps ..

you pay zero for the future (always that price) but something for an option .. and this something depends on your expected payoff, which is directly proportional to your vol levels .. however, for a future, you just solve for the fwd price/strike and pay zero .. its independent of your underlying vol ..

perhaps someone can provide a much more sane explanation :)
From what i understood so far the option is a transfer of risk, from the buyer to the seller.+ there is no obligation for the buyer to exercise his option if it is out of the money. whereas the in the futures and forward markets it is an obligation of the buyer.
Please feel free to comment:))
 
Top