I'm working on a quant interview question from the book called Quant Job Interview Questions And Answers (by Mark Joshi and other authors). I cannot understand the following question(not the answer, but the question itself):

Question 5.2: Suppose an asset takes values from a discrete set $v(j)$ and the probability of $v(j)$ is $p(j)$. Write an algorithm that produces the random variable for this asset from a uniformly distributed random variable.

What is the meaning of "produces the random variable for this asset from a uniformly distributed random variable", can any expert give an example to show what it means? Really appreciate your help!


The question requires you to provide a method which uses uniform random variables and transforms them to generate realizations of the described asset values.

To give a bit more general answer: this is solved by the inverse transform sampling method. The main idea is to obtain realizations of a random variable $x$ with any given distribution function $F(x)$, by using random numbers $u$ ~ $U(0,1)$ and transforming them.

To do this, you need first need to obtain the distribution function $F(x)$ (in your case you have a probability mass function to begin with), and calculate the inverse cdf $F^{-1}(x)$. Finally, for $u$ ~ $U(0,1)$, the values $x = F^{-1}(u)$ have a distribution $F(x)$.

  • $\begingroup$ Thanks a lot for the quick response, detailed explanation! Really appreciate it! $\endgroup$ – M00000001 Nov 13 at 17:01

Say your asset can take the discrete values {1,2,3,4} with probabilities {0.4, 0.1, 0.2, 0.3}.

The question is to derive a sampling procedure that returns either {1,2,3,4} with the right probabilities according to the underlying distribution.

The solution is to use a random uniform variable ($u \sim U(0,1)$)and allocate it based on the following:

if $u < 0.4 \implies 1$
if $u \geq 0.4, u < 0.5 \implies 2$
if $u \geq 0.5, u < 0.7 \implies 3$
if $u > 0.7\implies 4$

  • $\begingroup$ Thanks a lot for the quick response and great example! Really appreciate it! $\endgroup$ – M00000001 Nov 13 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.