2
$\begingroup$

Can some of you help me with following exercise?

Provide a procedure to generate realizations of a random variable with CDF (cumulative distribution function) $Fx(x)$ given by:

$Fx(x)=(x+1)/4$ if $-1<x<0$

$Fx(x)=(x+3)/4$ if $0<=x<1$

What is the meaning of generate realizations of random variable?

Thank all!

$\endgroup$

1 Answer 1

5
$\begingroup$

I think what is meant is: produce (pseudo-) random numbers. Note that for a distribution function $F$ and its inverse $F^{-1}$ and a uniform random variable $U$ it holds that $ F^{-1}(U) $ has distribution $F$. You an google random number generation and find this procedure. In you case:

  1. find the inverse of $F$
  2. Generate uniform random variables
  3. Apply $F^{-1}$

Then you are done. Which programming language do you use?

Edit: As remarked by Macro there is an atom at $0$ with probabilty $\frac12$. I think we can still use the inverse in the following way:

  1. find the inverse for $x \in [-1,0)$ and $x \in (0,1]$
  2. Generate a uniform $U$
  3. Call the generated rv $X$

    3.a) If $U \in [0,\frac14]$ then apply $F^{-1}$ as definded on the left of $0$ and set $X = F^{-1}(U)$

    3.b) If $U \in (\frac14,\frac34)$ then set $X = 0$

    3.c) If $U \in [\frac34,1]$ then apply $F^{-1}$ as definded on the right of $0$ and set $X = F^{-1}(U)$.

This should take care for the atom. Note that I did not care about open or closed intervals in the definition above as the probability for the uniform to reach the the point at the interval end is zero.

$\endgroup$
7
  • $\begingroup$ No, I am not using a programming language.Is a normal exercise of statistics. $\endgroup$
    – lui14
    Commented Feb 15, 2013 at 13:06
  • $\begingroup$ there you can get unform random variables with a function and then you apply the inverse ... you can make it in Excel! :) $\endgroup$
    – Richi W
    Commented Feb 15, 2013 at 13:25
  • $\begingroup$ Oh: I read Excel ... exercise .. anyways, the path should be clear. Best,R $\endgroup$
    – Richi W
    Commented Feb 15, 2013 at 13:25
  • $\begingroup$ Macro yes, you are right, I missed the discontinuity. @lui14 please look at Macro's remark! $\endgroup$
    – Richi W
    Commented Feb 15, 2013 at 15:05
  • $\begingroup$ @Macro: inverse transform sampling should be possible here when using the generalized inverse, i.e. $F^{-1}(u) = \inf\;\{x \mid F(x)\geq u, 0<u<1\}$ $\endgroup$
    – mogron
    Commented Feb 15, 2013 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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