ABSTRACT (original article): The simplicial depth (SD) is a celebrated tool defining elements of nonparametric and robust statistics for multivariate data. While many properties of SD are well-established, and its applications are abundant, explicit expressions for SD are known only for a handful of the simplest multivariate probability distributions. This paper deals with SD in the plane. It (i) develops a one-dimensional integral formula for SD of any properly continuous probability distribution, (ii) gives exact explicit expressions for SD of uniform distributions on (both convex and non-convex) polygons in the plane or on the boundaries of such polygons, and (iii) discusses several implications of these findings to probability and statistics: (a) An upper bound on the maximum SD in the plane, (b) an implication for a test of symmetry of a bivariate distribution, and (c) a connection of SD with the classical Sylvester problem from geometric probability. CITATION (original article): Mendroš, E. and Nagy, S. (2025). Explicit bivariate simplicial depth. Journal of Multivariate Analysis, Volume 205, 105375. https://doi.org/10.1016/j.jmva.2024.105375
The simplicial depth (SD) is a renowned tool in nonparametric and robust statistics for multivariate data. The simplicial depth of a point 𝑥 with respect to a probability measure P in the plane, denoted as SD(𝑥, P), is defined as the probability that 𝑥 lies inside the convex hull of a random sample of three points drawn from P, i.e., SD(𝑥, P) = Pr(𝑥 ϵ )), where , are independent and identically distributed random points from P. In a sense, the simplicial depth provides a means to expand the notion of quantiles beyond one-dimensional data and into multi-dimensional spaces. Despite its well-established properties and numerous applications, explicit formulas for SD are available only for a few basic multivariate probability distributions. In this notebook, we derive an explicit expression for the simplicial depth of any given point 𝑥 in the plane with respect to a uniform probability measure P defined on a convex polygon (see (a), (d), and (g)), as well as on the boundary of a convex polygon (see (c), and (h)). Furthermore, several additional examples related to the original paper are included (see (b), (e), (f)).
conv(,,
X
1
X
2
X
3
X
1,
X
2
X
3
(a) Explicit SD of uniform bivariate distribution defined on a square
(a) Explicit SD of uniform bivariate distribution defined on a square
In[]:=
$Assumptions=0<=x<=1&&0<θ<π&&0<=y<=x;
An auxiliary function which calculates the angle between line segments XY and YZ.
Input: Three two-dimensional points X,Y,Z .
Output: Angle ∠XYZ.
Input: Three two-dimensional points X,Y,Z .
Output: Angle ∠XYZ.
In[]:=
Angle[X_,Y_,Z_]:=ArcCos[Dot[X-Y,Z-Y]/(Norm[X-Y]*Norm[Z-Y])];
An auxiliary function which calculates the area of a triangle given two of its vertices and two adjacent angles.
Input: Angle γ, angle δ , vertex X (two-dimensional), vertex Y (two-dimensional).
Output: Area of the corresponding triangle.
Input: Angle γ, angle δ , vertex X (two-dimensional), vertex Y (two-dimensional).
Output: Area of the corresponding triangle.
In[]:=
ASA[γ_,δ_,X_,Y_]:=1/2*(EuclideanDistance[X,Y])^2*Sin[γ]*Sin[δ]/Sin[γ+δ];
Vertices of the square.
In[]:=
a={-1,1};b={1,1};c={1,-1};d={-1,-1};
Quantities needed to evaluate SD as defined prior to Theorem 4 in the main paper. Here the splitting line p was chosen to be always parallel to horizontal axis.
In[]:=
τ2=Angle[{x,y},b,a];τ3=Angle[a,{x,y},{2,y}];a1=(1-x)*(1-y)/2;ψ2=Angle[{x,y},d,c];ψ3=Angle[c,{x,y},{-2,y}];b1=(1+x)*(1+y)/2;
Probability of random point belonging to upper and lower part of the square, respectively.
In[]:=
ProbU=1/2*(1-y);ProbL=1/2*(1+y);
Piecewise parts of semicircular distribution functions F and G.
In[]:=
Part1F[θ_,x_,y_]:=(1-x)^2*Tan[θ]/2;Part2F[θ_,x_,y_]=FullSimplify[a1+ASA[τ2,θ-τ2,b,{x,y}]];Part3F[θ_,x_,y_]=FullSimplify[2*(1-y)-((1+x)^2)*Tan[π-θ]/2];Part1G[θ_,x_,y_]:=(1+x)^2*Tan[θ]/2;Part2G[θ_,x_,y_]=FullSimplify[b1+ASA[ψ2,θ-ψ2,d,{x,y}]];Part3G[θ_,x_,y_]=FullSimplify[2*(1+y)-((1-x)^2)*Tan[π-θ]/2];
Semicircular distribution functions F and G.
(*F[θ_,x_,y_]=Simplify[1/Part3F[π,x,y]*Piecewise[{{Part1F[θ,x,y],0<θ<=τ2},{Part2F[θ,x,y],τ2<θ<=τ3},{Part3F[θ,x,y],τ3<θ<π}}]];G[θ_,x_,y_]=Simplify[1/Part3G[π,x,y]*Piecewise[{{Part1G[θ,x,y],0<θ<=ψ2},{Part2G[θ,x,y],ψ2<θ<=ψ3},{Part3G[θ,x,y],ψ3<θ<π}}]];*)
In[]:=
F[θ_,x_,y_]=
;G[θ_,x_,y_]=
;
|
|
Semicircular density functions f and g.
(*f[θ_,x_,y_]=Simplify[D[F[θ,x,y],θ]];g[θ_,x_,y_]=Simplify[D[G[θ,x,y],θ]];*)
In[]:=
f[θ_,x_,y_]=
;g[θ_,x_,y_]=
;
|
|
The following code calculates the integral of the function f(θ)G(θ)(1-G(θ))dθ over the interval θ∈(0,π). This integral is broken down into five components: I1,I2,I3,I4,I5. Each component corresponds to a specific sub-interval of the original interval. These sub-intervals are: (0,ψ2), (ψ2,τ2), (τ2,ψ3), (ψ3,τ3),(τ3,π). The functions Int1 through Int5 are the antiderivatives corresponding to each of these sub-intervals. These functions were utilized to expedite the computation process.
In[]:=
Int1[x_,y_,θ_]=SimplifyIntegrate*Tan[θ]*1-Tan[θ],θ
2
(x-1)
4(1-y)
2
Sec[θ]
2
(1+x)
4(1+y)
2
(1+x)
4(1+y)
Out[]=
2
(-1+)
2
x
2
Sec[θ]
2
(1+x)
3
Tan[θ]
192(-1+y)
2
(1+y)
In[]:=
I1[x_,y_]=FullSimplify[Int1[x,y,ψ2]-Int1[x,y,0]]
Out[]=
(-5+x)(1+y)
2
(-1+x)
192(-1+y)
In[]:=
Int2[x_,y_,θ_]=SimplifyIntegrate*(2(1+x)-(1+y)Cot[θ])*1-(2(1+x)-(1+y)Cot[θ]),θ
2
(x-1)
4(1-y)
2
Sec[θ]
1
4
1
4
Out[]=
-Csc[θ]Sec[θ]5-4+2y++(-3+4+2y+)Cos[2θ]-4x(1+y)Log[Cot[θ]]Sin[2θ]
2
(-1+x)
2
x
2
y
2
x
2
y
128(-1+y)
In[]:=
I2[x_,y_]=FullSimplify[Int2[x,y,τ2]-Int2[x,y,ψ2]]
Out[]=
2
(-1+x)
2
y
x-y
-1+xy
32
2
(-1+y)
In[]:=
Int3[x_,y_,θ_]=SimplifyIntegrate(1-y)*(2(1+x)-(1+y)Cot[θ])*1-(2(1+x)-(1+y)Cot[θ]),θ
1
4
2
Csc[θ]
1
4
1
4
Out[]=
1
192
2
x
2
y
In[]:=
I3[x_,y_]=FullSimplify[Int3[x,y,ψ3]-Int3[x,y,τ2]]
Out[]=
2
(-1+x)
2
y
96(1+y)
2
(-1+y)
In[]:=
Int4[x_,y_,θ_]=SimplifyIntegrate(1-y)*1+Tan[θ]*-Tan[θ],θ
1
4
2
Csc[θ]
2
(1-x)
4(1+y)
2
(1-x)
4(1+y)
Out[]=
2
(-1+x)
2
(-1+x)
64
2
(1+y)
In[]:=
I4[x_,y_]=FullSimplify[Int4[x,y,τ3]-Int4[x,y,ψ3]]
Out[]=
-(-1+y)(-1+x)(x+y)+2(1+x)(1+y)Log-2(1+x)(1+y)Log
2
(-1+x)
1+x
-1+y
-1+x
1+y
32(1+x)
2
(1+y)
In[]:=
Int5[x_,y_,θ_]=SimplifyIntegrate*1+Tan[θ]*-Tan[θ],θ
2
(1+x)
4(1-y)
2
Sec[θ]
2
(1-x)
4(1+y)
2
(1-x)
4(1+y)
Out[]=
2
(-1+)
2
x
2
Sec[θ]
2
(-1+x)
3
Tan[θ]
192(-1+y)
2
(1+y)
In[]:=
I5[x_,y_]=FullSimplify[Int5[x,y,π]-Int5[x,y,τ3]]
Out[]=
-(-1+y)(5+7y+x(8-x+(4+x)y))
2
(-1+x)
192(1+x)
2
(1+y)
In an analogous manner, here we calculate the integral of the function g(θ)F(θ)(1-F(θ))dθ over the interval θ∈(0,π).
In[]:=
Jnt1[x_,y_,θ_]=SimplifyIntegrate*(4(1-y))*Tan[θ]*1-(4(1-y))*Tan[θ],θ
2
(1+x)
4(1+y)
2
Sec[θ]
2
(1-x)
2
(1-x)
Out[]=
-(6(-1+y)+)
2
(-1+)
2
x
2
Sec[θ]
2
(-1+x)
3
Tan[θ]
192(1+y)
2
(-1+y)
Function Upper corresponds to the first of the two sums in Theorem 4 of the main paper.
Function Lower corresponds to the second of the two sums listed in Theorem 4 of the main paper.
Can be further (manually) simplified to
Using axial symmetries of the square we obtain the exact SD of uniform distribution on a square in the following form.
(b) Application: Sylvester probability on the uniform square
(b) Application: Sylvester probability on the uniform square
Example from Section 4.3 of the main paper. This example examines the probability that four bivariate points, chosen uniformly at random from a full-dimensional rectangle, form a convex quadrilateral. This probability is known to be 25/36, see e.g. Pfiefer, R. E., (1989). The Historical Development of J. J. Sylvester’s Four Point Problem. Using the explicit simplicial depth formula derived earlier offers an alternative method for its calculation.
(c) Explicit SD of uniform bivariate distribution defined on the boundary of a square
(c) Explicit SD of uniform bivariate distribution defined on the boundary of a square
An auxiliary function which calculates the length of the side of a triangle given two of its vertices and two adjacent angles.
Input: Angle β, angle γ , point X (two-dimensional), point Y (two-dimensional).
Output: Length of the corresponding side of the triangle.
Input: Angle β, angle γ , point X (two-dimensional), point Y (two-dimensional).
Output: Length of the corresponding side of the triangle.
Quantities needed to evaluate SD as defined in Theorem 5 in the main paper. Note that the splitting line p is always chosen to be parallel to horizontal axis.
Semicircular distribution functions F and G and semicircular density functions f and g.
Components I1,I2,I3,I4,I5 and J1,J2,J3,J4,J5 here are derived similarly to (a), hence only the results are presented.
Components I1,I2,I3,I4,I5 and J1,J2,J3,J4,J5 here are derived similarly to (a), hence only the results are presented.
Function Upper corresponds to the second of the two sums listed in Theorem 5 of the main paper.
Function Lower corresponds to the second of the two sums listed in Theorem 5 of the main paper.
Can be further (manually) simplified to
Using axial symmetries of a square we obtain the exact SD of all interior points with respect to the uniform distribution on the boundary of the square.
Derivation of SD of the boundary points is straightforward and omitted.
(e) Application: Numerical approximation of Sylvester probability on triangle
(e) Application: Numerical approximation of Sylvester probability on triangle
(f) Application: Exact SD in the centroid of a triangle
(f) Application: Exact SD in the centroid of a triangle
(g) Algorithm: Explicit SD of uniform bivariate distribution defined on a convex polygon
(g) Algorithm: Explicit SD of uniform bivariate distribution defined on a convex polygon
A supplementary intersect function is designed to compute the intersection point of a line and a line segment in a two-dimensional plane.
Input :
L1: A list of two points that define a line. Each point is represented as a list of two coordinates.
L2: A list of two points that define a line segment. Each point is represented as a list of two coordinates.
Output:
If the line and the line segment do not intersect, the function returns an empty set.
If they do intersect, the function returns the coordinates of the intersection point.
Input :
L1: A list of two points that define a line. Each point is represented as a list of two coordinates.
L2: A list of two points that define a line segment. Each point is represented as a list of two coordinates.
Output:
If the line and the line segment do not intersect, the function returns an empty set.
If they do intersect, the function returns the coordinates of the intersection point.
The functions I1, I2, and I3 are defined in Theorem 4 of the main paper. The primitive functions of the integrals involved in these definitions are detailed in Section S.1 of the supplementary material.
Function to calculate exact SD of a polygon. For details see Theorem 4 in the main paper.
Input :
x1: An x-coordinate of point whose simplicial depth is to be calculated.
x2: An y-coordinate of point whose simplicial depth is to be calculated.
Y: A list of angularly sorted vertices of a convex polygon. Each point is represented as a list of two coordinates.
P: A convex hull of vertices in Y (Polygon[Y]).
Output:
Exact simplicial depth of point (x1,x2) with respect to uniform distribution defined on convex polygon induced by vertices in Y.
Input :
x1: An x-coordinate of point whose simplicial depth is to be calculated.
x2: An y-coordinate of point whose simplicial depth is to be calculated.
Y: A list of angularly sorted vertices of a convex polygon. Each point is represented as a list of two coordinates.
P: A convex hull of vertices in Y (Polygon[Y]).
Output:
Exact simplicial depth of point (x1,x2) with respect to uniform distribution defined on convex polygon induced by vertices in Y.
3D plotting function of exact SD of a polygon.
Input :
Y: A list of angularly sorted vertices of a convex polygon.
Output:
3D plot of exact SD of uniform distribution defined on convex polygon induced by vertices in Y.
Input :
Y: A list of angularly sorted vertices of a convex polygon.
Output:
3D plot of exact SD of uniform distribution defined on convex polygon induced by vertices in Y.
Contour plotting function of exact SD of a polygon.
Input :
Y: A list of angularly sorted vertices of a convex polygon.
Output:
Contour plot of exact SD of uniform distribution defined on convex polygon induced by vertices in Y.
Input :
Y: A list of angularly sorted vertices of a convex polygon.
Output:
Contour plot of exact SD of uniform distribution defined on convex polygon induced by vertices in Y.
Examples
Examples
(i) Pentagon
(ii) Octagon
(iii) Trapezoid
(h) Algorithm: Explicit SD of uniform bivariate distribution defined on a boundary of a convex polygon
(h) Algorithm: Explicit SD of uniform bivariate distribution defined on a boundary of a convex polygon
Function to calculate exact SD of a uniform distribution supported on a boundary of a polygon. For details see Theorem 5 in the main paper.
Input :
x1: An x-coordinate of point whose simplicial depth is to be calculated.
x2: An y-coordinate of point whose simplicial depth is to be calculated.
Y: A list of angularly sorted vertices of a convex polygon. Each point is represented as a list of two coordinates.
P: A convex hull of vertices in Y (Polygon[Y]).
Output:
Exact simplicial depth of point (x1,x2) with respect to uniform distribution defined on a boundary of the convex polygon induced by the vertices in Y.
Input :
x1: An x-coordinate of point whose simplicial depth is to be calculated.
x2: An y-coordinate of point whose simplicial depth is to be calculated.
Y: A list of angularly sorted vertices of a convex polygon. Each point is represented as a list of two coordinates.
P: A convex hull of vertices in Y (Polygon[Y]).
Output:
Exact simplicial depth of point (x1,x2) with respect to uniform distribution defined on a boundary of the convex polygon induced by the vertices in Y.
Plotting functions for boundarySD.
Examples
Examples
(i) Triangle (boundary)
(ii) Trapezoid (boundary)
(iii) Pentagon (boundary)
(iv) Octagon (boundary)
For more examples click on the grid to select polygon vertices. Make sure the vertices are in convex position. The chosen vertices will be stored in the variable Y. To plot the exact SD for your chosen polygon, execute the code below the grid.
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Explicit bivariate simplicial depth
by Erik Mendroš & Stanislav Nagy
Wolfram Community, STAFF PICKS, October 23, 2024
https://community.wolfram.com/groups/-/m/t/3306564
by Erik Mendroš & Stanislav Nagy
Wolfram Community, STAFF PICKS, October 23, 2024
https://community.wolfram.com/groups/-/m/t/3306564