statistics help needed.

Hey guys I've got several questions about statistics.

Here's the first one.

1. Suppose X is a discrete random variable that takes on the three values x1, x2, x3 with probabilities p1, p2, p3 respectively. Describe how you could generate a random sample from X if all you had access to were a list of numbers generated at random from the interval [0, 1].

2. Suppose X is a continuous random variable with c.d.f. FX(x) = P(X <= x). To make things easier, suppose further that X takes on values in an interval [a, b] (do allow for a to be −1 and b to be +1).

Let Y be the random variable defined by Y = FX(X). This looks strange, but is perfectly
valid since FX is just a function, and you are allowed to take functions of random variables.

Your problem: show that Y distributed U[0, 1].

Method: calculate the c.d.f. Y , FY (y) = P(Y<=y ), for all real y. Replace Y with FX(X),
and consider when you can take the inverse of FX.
Taking the inverse of FX is not always possible, in particular, for x < a and x > b. Consider
those cases separately.
You will find that the c.d.f. of Y is 0 for y < 0, y for 0<y<1 and 1 for y > 1, so indeed
Y distributed U[0, 1].
An important application of this fact is that if u is a random selection from the interval [0, 1], F^(−1) X (u) is a random selection from X.

Alright..for no 1. I'm wondering how can the random variable have 3 values when the space we are taking the list of numbers only has 0 and 1?? I'm also not too clear on what they mean by generate a random sample??

For no 2. I've tried substituting in everything but I am not sure how to find the inverse of a probability. I've gotten F'(X) = p(x) - p(x min).

Also does anyone know how to program in R?

I did #2 in my graduate level statistics course. I don't remember how to prove it, but it was very short (2-3 lines) and it does not involve the inverse.
I think the proof of #2 is along the lines of the following:

F[F^(-1)(x)] = x is the cdf of Unif[0,1]

cdf is unique for each distribution.

Thus F^(-1)(x) ~ Unif[0,1]
Hmm. well i've gotten the 2nd question. NOw down for the first question

And here's another question:

2. Suppose X is a discrete random variable that takes on values from {1, 2, 3, . . .} with probabilities
{p1, p2, p3, . . .}. If u is a number selected at random from [0, 1] explain why

min {sum from i=1 to n of p subscript i >= u}

can be considered as a random selection from X.