Another way to do the sampling (taking advantage of the built in Sphere
function and RandomPoint
functionality (modified from a similar question on sampling from the surface of the sphere
distanceDistributionOnHalfSphere[dimensionality_, nSamples_:10^5] :=
With[{
(* take a few extra samples account for loss *)
randomPointsOnSurfaceOfNSphere = RandomPoint[Sphere[dimensionality], {4*nSamples, 2}],
(* define an operator that deletes points when either last coordinate is negative *)
upperHemisphere = DeleteCases[{{___, x_}, {___, y_}} /; (Negative[x] || Negative[y])]
},
(* apply operator to the list and compute list of distances *)
EuclideanDistance @@@ upperHemisphere @ randomPointsOnSurfaceOfNSphere
]
(* Evaluate mean of the sample *)
MeanAround /@ distanceDistributionOnHalfSphere /@ Range[10]
(The $N=3$ result is in agreement with @flinty's result*)