Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

A random number generator generated random values from the Standard Uniform distribution Uniform(0,1). Call this random variable, U. Starting with a random value u from U, show all the steps necessary to generate a continuous random variable with the density function f(x) = 0.5(1+x), where -1 <= x <= 1.

I am doing this for a practice exam so an exact answer is not as important to me as the proper solution. I honestly have no clue how to go about this problem and have tried using similar psuedo code problems for Uniform(0,1) but still haven't been able to figure this one out in particular.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Suppose $X$ is a random variable with that distribution on $[-1,1]$ and $Y$ is uniformly distributed on $[0,1]$. Note that for $x \in [-1,1]$ $$\mathbb{P}(X < x) = \int_{-1}^x\frac{1+s}{2}ds = \frac{(x+1)^2}{4} = \mathbb{P}(Y < \frac{(x+1)^2}{4}) = \mathbb{P}(2 \sqrt{Y} - 1 < x).$$

So $2\sqrt{Y} - 1$ has exactly the given distribution. This procedure works in principle for other distributions. However, it works so well here because

  1. the probability on the left has an explicit formula and
  2. that formula has a nice inverse.

You will not always be so lucky. For example, to generate a normally distributed random variable from a uniform one requires another smart trick.

share|improve this answer

Hints: (1) Find an increasing function $g:[0,1]\to[0,1]$ such that the density of $g(U)$ is $x\mapsto2x$ on $[0,1]$. (2) Find an affine transformation $a$ such that $a(0)=-1$ and $a(1)=1$. (3) Check that $a(g(U))$ solves your problem.

share|improve this answer
    
Hint: You need to find a transformation function $F$ where $F^{-1}(x)$ $x \in [-1,1]$, or more simply with $u=(x+1)/2$ substitution $F^{-1}(u)$ for $u \in [0,1]$. Here F is the cdf for the desired pdf. –  karakfa Dec 13 '12 at 21:26
    
@karakfa Whom is your comment aimed at? –  Did Dec 14 '12 at 6:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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