Uniform Sampling points on a line using 2 Uniform distributions

85 Views Asked by At

I have been struggling with this problem for quite some time but I am not sure how to proceed.

So I am given a sampling algorithm : We would like to uniformly sample points on a line between A and B. Start with sampling $x,y$ from $U([0,1])$ (a uniform distribution),then the point $P = \frac{xA + yB}{x+y}$.

For the sake of simplicity I let A=0 and B=1 and generated some results in R to see if the points are uniformly sampled, but they are not. So I would like to understand why this sampling algorithm does not yield uniform samples.

Some Work I have done: I tried looking into some prior questions but I could not find a match. I think finding the cdf and showing its not a straight line (like the one for uniform distribution) would suffice to show that the algorithm does not yield uniform sampling, however I am struggling to find such CDF. Any help would be appreciated.

2

There are 2 best solutions below

3
On BEST ANSWER

Without loss of generality $A=0$ and $B=1$. We have to verify that $Q=X/(X+Y)$ is not uniform. To this end, we compute $\Pr(X<Yr|Y=y)=1$ if $yr>1$ and $\Pr(X<Yr|Y=y)=yr$ if $yr<1$ which implies $\Pr(X<Yr)=\int_0^1yrdy=\frac{r}{2}$ if $r<1$ and $\Pr(X<Yr)=\int_{1/r}^1dy+\int_0^{1/r}yrdy=1-\frac{1}{2r}$ if $r>1.$

This leads for $0<q<1$ to $F(q)=\Pr(X/(X+Y)<q)=\Pr(X/Y\leq q/(1-q) )$ which is

$F(q)=\frac{q}{2(1-q)}$ and $F'(q)=\frac{1}{2(1-q)^2}$ if $0<q<1/2$,

and also $F(q)=\frac{2q-1}{q}$ and $F'(q)=\frac{1}{2q^2}$ if $1/2<q<1.$

2
On

It doesn't work because the sum $x+y$ will not be uniformly distributed. You should be able to sample uniformly if you use one uniform variable; e.g., $$P = (1-x) A + x B,$$ where $x$ is uniform on $[0,1]$. Then when $x = 0$, $P = A$, and when $x = 1$, $P = B$.

It's also worth mentioning that $A$ and $B$ need not be limited to $\mathbb R$. They can be arbitrary points in $\mathbb R^n$, and you will still get a uniform sampling on the line segment joining $A$ and $B$.