Given a set $S_n$ of $n$ points selected uniformly at random in a $d$-ball, I want to estimate the average length of the longest side of a triangle having as vertices any three distinct points of $S_n$, when $n\gg d\gg 1$. Below you can find my approach, which unfortunately does not scale well with the number of points $n$ nor the number of dimensions $d$. Is it possible to improve it to make it more scalable?
n:=300; d:=30;
p := RandomPoint[Sphere[d], {n}];
x:=EuclideanDistance @@@ Subsets[p, {3}][[1 ;; , 1 ;; 2]];
y:=EuclideanDistance @@@ Subsets[p, {3}][[1 ;; , 2 ;; 3]];
z:=EuclideanDistance @@@ Drop[Subsets[p, {3}], None, {2}];
Mean[Map[Max, Transpose[{x,y,z}]]]
n := 300; d := 30; p := RandomPoint[Sphere[d], {n/3, 3}]; xyz := Apply[EuclideanDistance, Subsets[#, {2}] & /@ p, {2}]; Mean[Map[Max, Transpose[xyz]]]
? $\endgroup$Ball[]
$\endgroup$p
,x
,y
andz
withSetDelayed
,p
is reevaluated every time it appears inx
(similarly fory
andz
) . That is, a differentp
is used when you getx
,y
andz
. $\endgroup$