triangle_distance, an Octave code which estimates the expected value of the distance between a pair of points randomly selected in a triangle in 2D.
This problem is notably more complicated than when the sampling region is a square. In particular, the probability density function for the distance seems to be known only for special cases, such as a right triangle or equilateral triangle.
The computer code and data files made available on this web page are distributed under the MIT license
triangle_distance is available in a MATLAB version and an Octave version and a Python version.
octave_distance, an Octave code which estimates the typical distance between a pair of points randomly selected from the surface or interior of a geometric object such as a circle, disk, sphere, cube.