0

A stick of length 1 is broken at a uniformly random point, yielding two pieces. Let X and Y be the lengths of the shorter and longer pieces, respectively, and let R=X/Y be the ratio of the lengths of X and Y.

(a) Find the CDF and PDF of R.

(b) Find the expected value of R (if it exists).

(c) Find the expected value of 1/R (if it exists).

(d)Use simulations in R to gain some understanding about the distribution of the random variable R. Numerically estimate the expected value of R and 1/R.

So, the value of expectation of R and 1/R do not exist, as they do not converge. However, R is saying that the values converge and gives an answer. Can someone explain why. (R does not converge as the integral is not bound at infinity, while 1/R is not bound at 0.

My R code is as follows:

n <- 100000
r <- numeric(n)

x <- runif(n)
y <- 1-x
r <- x/y

mean(r)
mean(1/r)
  • Since $R$, as the ratio of a smaller (non-negative) length to a larger length, is *obviously* bounded between $0$ and $1$, all its moments must exist. – whuber Oct 29 '17 at 14:47
  • Isn't the integral for expectation of uniform to be calculated from 0 to infinity? –  Oct 29 '17 at 15:00
  • $R$ does not have a uniform distribution. Regardless, let's address the obviousness claim: all expectations are probability-weighted averages of values of random variables. For a random variable, like $R$, whose values are bounded between $a$ and $b$ (such as $a=0$ and $b=1$), the average *must* lie between $a$ and $b$. Therefore $E[R]$ exists and must lie between $0$ and $1$. (It equals $\log(4)-1\approx 0.386294$.) – whuber Oct 29 '17 at 15:16

1 Answers1

2

Here's a): Let $U \sim \text{Uniform}(0,1)$.

\begin{align*} P(R \le r) &= P(X(1+r) \le r) \\ &= P(\text{min}(U,1-U) \le r/(1+r))\\ &= 1 - P(U > r/(1+r), U < 1/(1+r)) \\ &= 1 - \frac{1}{1+r} + \frac{r}{1+r}. \end{align*}

So $F_R(r) = 2r(1+r)^{-1}$ for $0 < r < 1$. And $f_R(r) = 2(1+r)^{-2} $.

b and c)

$E[R] = 2\int_0^1 r (1+r)^{-2} dr $ exists. While $E[1/R] = 2\int_0^1 r^{-1} (1+r)^{-2} dr $ does not.

Also, your code is incorrect. Try this

# generate
n <- 100
u <- runif(n)
mat <- cbind(u, 1-u)
x <- apply(mat, 1, min)
y <- apply(mat, 1, max)
r <- x/y


# actual density
func <- function(r){
  1 + min(r/(1+r), .5) - max(1/(1+r), .5)
}
rvals <- seq(0,1,.01)
derp <- sapply(rvals, func)

# plot with true overlay
plot(ecdf(r))
lines(rvals,derp, col = "red")

# plot histogram of r
hist(r)

# plot histogram of 1/r (super heavy tails)
hist(1/r) 
Taylor
  • 18,278
  • 2
  • 31
  • 66
  • I found a already, but R and 1/R don't exist right? And the code you've given, do I just find expectation of x and y? –  Oct 29 '17 at 02:40
  • @CheggKidd see update – Taylor Oct 29 '17 at 13:32
  • Your work can be hugely simplified by computing $$\Pr(R\le r)=\Pr(X/(1-X)\le r)=\Pr(X\le r/(1+r))=\min(1, 2r/(1+r))$$ for all $r\ge 0$. Differentiation shows the limiting density at $0$ is positive, whence $1/R$ must have infinite expectation according to the analysis at https://stats.stackexchange.com/a/299765/919. Efficient simulation of $R$ can be carried out with `r – whuber Oct 29 '17 at 14:57
  • @whuber why is $\Pr(R\le r)=\Pr(X/(1-X)\le r)$? $R = \frac{min(X,1-X)}{max(X,1-X)}$ – Taylor Oct 29 '17 at 15:12
  • $R$ is defined to be $X/(1-X)$. (I see now that your "$X$" and the "$X$" in the question have different meanings. I am using the meaning from the question itself.) – whuber Oct 29 '17 at 15:18
  • 1
    @whuber yep sorry. I did this late last night; I will make some changes. – Taylor Oct 29 '17 at 15:18
  • I'll tell you an interpretation that I understand tells me that 1/R doesn't exist. Since the expectation (or mean) of 1/R is >1, it is non existent right? According to the R (programming language) mean function, mean(1/R) is 7.743758. –  Oct 29 '17 at 16:22
  • @CheggKidd no you can have means greater than $1$ that are still finite. Check out the link above, or try taking the anti-derivative and see what happens when you try to use those bounds. Recall that $\log(0) = -\infty$. And regarding your code, the law of large numbers only tells us what happens when $n \to \infty$; the $n$ in my code is much smaller than that. – Taylor Oct 29 '17 at 18:09
  • So how do I interpret the results from the simulation and match it with the integral that I got? I'm talking about your simulation code. –  Oct 29 '17 at 18:16
  • @CheggKidd $E[R^{-1}] = \infty$. If you want to "verify" this better, jack up n until you overflow. Imho this is pointless; that's why I did the histogram instead--so you can see the fat tails. – Taylor Oct 29 '17 at 18:20
  • Oh fair enough. I'm pretty new to stats and was wondering what fat tails mean in a histogram? What do they mean? –  Oct 29 '17 at 18:22
  • @CheggKidd this sounds like it should be a new question. Having conversations in the comments is generally frowned upon. But, very quickly, it means that the pmf or pdf evaluations decrease relatively slowly. It's what makes certain expectations come out to be infinity (or in other words they don't exist). Also ps welcome to the site : – Taylor Oct 29 '17 at 18:31