0

Suppose $n$ points are uniformly and randomly selected in a square bounded by lines $ x=0,y=0,x=1,y=1.$ Let $X$ be the distance of a point from the centre $(1/2,1/2)$.Can we analytically calculate the density function of the range of $X$.i did a MATLAB simulation

for k=1:1000  
       for i=1:1000  
                x1(i)=rand();    
                x2(i)=rand();  
                y1(i)=rand();  
                y2(i)=rand();  

                d(i)=sqrt((x1(i)-0.5)^2+(y1(i)-0.5)^2);  
                range=max(d)-min(d);  
       end  
       r(k)=range  
end  
avg=sum(r)/1000  
plot(r) 

I got the average value of range as 0.67 .References and books for similar problems involving random distances between points are also requested
P.S:-Some experts are suggesting that my problem might be a duplicate of problem which talks about the average distance of a random point in a square .While the two problems might be apparently similar but my problem is different in that its aim to find the density function of the range $R$ of the distance of a random point from the centre of the square ,possibly as a function of $r$ itself just as talk of the pdf $f(y)$ of a random variable $Y$.Further ,while it is relatively straight forward to calculate the pdf of minimum and maximum of a rv ,it is an entirely different problem to compute the pdf of the range

AgnostMystic
  • 1,654
  • somebody kindly tell me how I can highlight the code part in a nice way and upload images – AgnostMystic May 19 '20 at 07:02
  • 1
    Hey, I was trying to make the code look nice! Why did you erase my changes? Also, it's not clear what you're asking, here. Do you think the answer is wrong, or what is your question? – Matti P. May 19 '20 at 07:09
  • @MattiP. did great job, let him to help you.... – Anton Vrdoljak May 19 '20 at 07:10
  • sorry @MattiP i just happened to add a couple of lines at a wrong time.I am extremely sorry – AgnostMystic May 19 '20 at 07:11
  • 3
    Related: https://math.stackexchange.com/questions/15580/what-is-average-distance-from-center-of-square-to-some-point – Matti P. May 19 '20 at 07:12
  • @MattiP. I think my question is clear .I am just asking whether there is some analytical way of finding density function the range of distances from A(1/2,1/2) of n random points in the above square as a function of distance of a point from A and the parameter n – AgnostMystic May 19 '20 at 07:16
  • That $0.67$ feels awfully high given that the distance to the corners (=the maximum) is $\sqrt{1/2}\approx0.707$. I got $\approx0.38$. Why is your code posting the average range of a sample of 1000 points? That's not what the title question is asking? – Jyrki Lahtonen May 19 '20 at 07:21
  • Oh, you really want the expected range. Then the question is underspecified. You need to fix the sample size (1000 in your code). If you let that $\to\infty$, then within each set you get closer and closer to the maximum. – Jyrki Lahtonen May 19 '20 at 07:24
  • @JyrkiLahtonen I re ran the code ..giving me the same results.And i think it is not surprising because we are computing the range .BTW, would you mind sharing your code or pointing whether there is something wrong with my code – AgnostMystic May 19 '20 at 07:38
  • That $0.38$ is the average of d. It was not clear to me initially that you had a double loop. Sorry about the confusion. – Jyrki Lahtonen May 19 '20 at 08:35
  • I did not understand that you are only interested in the distribution of the range variable. Anyway, my other point was that the result depends on the number of tests in the inner loop. Undoubtedly you know this, but without fixing the length of the inner loop we cannot have comparable numbers. – Jyrki Lahtonen May 19 '20 at 08:37
  • The main question really is that you describe a distribution, and are asking about the expected bevahior of the difference between maximum and minimum within a sample from that distribution. That was not clear. – Jyrki Lahtonen May 19 '20 at 08:45
  • Anyway, once you have the cumulative distribution, you can apply the principles outlined here to get the cdf of the maximum. Similarly for the minimum. – Jyrki Lahtonen May 19 '20 at 08:52
  • so kind of @JyrkiLahtonen.Will try to figure out – AgnostMystic May 19 '20 at 09:05
  • This paper is great and has some details towards goals such as yours: https://www.davidhbailey.com/dhbpapers/boxintegrals.pdf – Benedict W. J. Irwin May 19 '20 at 09:21

0 Answers0