0
$\begingroup$

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)
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – whuber Oct 29 '17 at 14:47
  • $\begingroup$ Isn't the integral for expectation of uniform to be calculated from 0 to infinity? $\endgroup$ – user180844 Oct 29 '17 at 15:00
  • $\begingroup$ $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$.) $\endgroup$ – whuber Oct 29 '17 at 15:16
2
$\begingroup$

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) 
$\endgroup$
  • $\begingroup$ 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? $\endgroup$ – user180844 Oct 29 '17 at 2:40
  • $\begingroup$ @CheggKidd see update $\endgroup$ – Taylor Oct 29 '17 at 13:32
  • $\begingroup$ 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 stats.stackexchange.com/a/299765/919. Efficient simulation of $R$ can be carried out with r <- (function(u){x<-pmin(u,1-u); x/(1-x)})(runif(1e4)). $\endgroup$ – whuber Oct 29 '17 at 14:57
  • $\begingroup$ @whuber why is $\Pr(R\le r)=\Pr(X/(1-X)\le r)$? $R = \frac{min(X,1-X)}{max(X,1-X)}$ $\endgroup$ – Taylor Oct 29 '17 at 15:12
  • 1
    $\begingroup$ @whuber yep sorry. I did this late last night; I will make some changes. $\endgroup$ – Taylor Oct 29 '17 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy