# Simulation of an exponentially distributed variable

A one-period jump diffusion model of a stock is the following: given the stock value at $T0$, $S(T0)$, the stock value at time $T$, $S(T) = S(T0)exp(x)exp(y)$. Given the inputs $m$, $s$, $pup$, $pdown$ and $\lambda$, and:

1. x is normally distributed with mean m and standard deviation s
2. y equals 0 with probability 1 – pup – pdown (i.e. no jump).
3. y is positive with probability pup; if it is positive , y is exponentially distributed with density p(y) = λexp(-λy) for y > 0.
4. y is negative with probability pdown; if it is negative, y is exponentially distributed with p(y) = λexp(λy) for y < 0.
5. x and y are uncorrelated & independent.

I am to write a MATLAB program that siumulates the stock prices. Two random numbers per trial are required:

1. A uniformly distributed random number that determines if a jump has occurred
2. An exponentially distributed random number that determines the size of the jump

I've transormed a uniform random variable to an exponential variable using $-ln(1 - U(a, b)) / \lambda$.

Where I'm confused is how we're using the uniformly distributed random number that determines if a jump has occurred given I am given pup and pdown. Also, why do I need an exponentially distributed random number for the jump size. I thought I just integrate the pdf? For some reason I struggle mightily with the exponential distribution.

• The way you mention it here, the stock value at time $T$ does not depend on $T$. Is that correct? That would be very strange indeed for a diffusion process. In your explanation, both $x$ and $y$ have fixed distributions that do not change with the passing of time ($T$). Mar 21, 2015 at 22:05

Let $B$ be the indicator of what type of jump occurs, if any; $B=-1$ when there's a negative jump, $B=1$ when there's a positive jump and $B=0$ if there is no jump. Then to determine the jump, you just need to generate $B$. According to your formulation,

$$P(B=-1) = p_{down}$$

$$P(B=1) = p_{up}$$

$$P(B=0) = 1-p_{up}-p_{down}$$

You can generate $B$ by generating a Uniform(0,1) variable $U$ and letting

$$B=-1 \ \ \ {\rm if} \ \ \ U \leq p_{down},$$

$$B=1 \ \ \ {\rm if} \ \ \ p_{down} \leq U \leq p_{down}+p_{up}$$

and

$$B=0 \ \ \ {\rm if} \ \ \ U \geq p_{down}+p_{up}$$

Examining the Uniform(0,1) CDF will make it clear why the probabilities work out correctly.

You could integrate out $Y$ if the question were to determine the distribution of $S(T)$ analytically but I think the point is to determine its distribution by simulation.

Note: Assuming you don't have a function to generate normally distributed variables, you will also have to generate more uniforms to simulate $X$. If you use the Box-Muller transform method of generating normals, you can simulate two normals for every two uniformly distributed variables.

• Note, that since you are to use MATLAB, drawing random numbers from many distributions is simple, e.g., randn() for normally distributed numbers, exprnd() for exponentiall distributed ones. Oct 3, 2011 at 8:12
• I am using MATLAB and generated uniform, normal, and exponentially distributed variables using rand, randn, and exprnd, respectively. This approach is the one I used. Oct 3, 2011 at 15:53