1 /******************************************************************************/
2 /* File:             HD.h                                                     */
3 /* Created by:       Rainer Dyckerhoff, Pavlo Mozharovskyi                    */
4 /* First published:  19.06.2015                                               */
5 /* Last revised:     19.06.2015                                               */
6 /*                                                                            */
7 /* Contains declarations of functions that compute the exact halfspace depth  */
8 /* of a point w.r.t. a data cloud.                                            */
9 /*                                                                            */
10 /******************************************************************************/
11 
12 enum HDalgs{
13 //	random = 0,
14 	recursive = 1,	// HD_DRS
15 	plane = 2,		// HDc2
16 	line = 3		//HD_Cmb
17 };
18 
19 /****************************************************************************/
20 /* HD_Comb computes the halfspace depth of a point z in d-space w.r.t.      */
21 /*   n data points passed in xx.                                            */
22 /*   HD_Comb implements the combinatorial algorithm (k = d-1) as described  */
23 /*   in Section 3.1 of "Exact computation of the halfspace depth" by        */
24 /*   Rainer Dyckerhoff and Pavlo Mozharovskyi (arXiv:1411:6927)             */
25 /*                                                                          */
26 /* Args:                                                                    */
27 /*   z  - the point to calculate the depth for (vector of dimension d),     */
28 /*   xx - the data w.r.t. which the depth has to be computed, (matrix of    */
29 /*        dimension n x d)                                                  */
30 /*   n  - number of the data points,                                        */
31 /*   d  - dimension of the Euclidean space.                                 */
32 /* Returns:                                                                 */
33 /*   depth of z w.r.t. xx in the interval [0,1].                            */
34 /****************************************************************************/
35 double HD_Comb(double* z, double** xx, int n, int d);
36 
37 /****************************************************************************/
38 /* HD_Comb2 computes the halfspace depth of a point z in d-space w.r.t.     */
39 /*   n data points passed in xx.                                            */
40 /*   HD_Comb2 implements the combinatorial algorithm (k = d-2) as described */
41 /*   in Section 3.2 of "Exact computation of the halfspace depth" by        */
42 /*   Rainer Dyckerhoff and Pavlo Mozharovskyi (arXiv:1411:6927)             */
43 /*                                                                          */
44 /* Args:                                                                    */
45 /*   z  - the point to calculate the depth for (vector of dimension d),     */
46 /*   xx - the data w.r.t. which the depth has to be computed, (matrix of    */
47 /*        dimension n x d)                                                  */
48 /*   n  - number of the data points,                                        */
49 /*   d  - dimension of the Euclidean space.                                 */
50 /* Returns:                                                                 */
51 /*   depth of z w.r.t. xx in the interval [0,1].                            */
52 /****************************************************************************/
53 double HD_Comb2(double* z, double** xx, int n, int d);
54 
55 /****************************************************************************/
56 /* HD_Rec computes the halfspace depth of a point z in d-space w.r.t.       */
57 /*   n data points passed in xx.                                            */
58 /*   HD_Rec implements the recursive algorithm (k = 1) as described in      */
59 /*   Section 3.3 of "Exact computation of the halfspace depth" by           */
60 /*   Rainer Dyckerhoff and Pavlo Mozharovskyi (arXiv:1411:6927)             */
61 /*                                                                          */
62 /* Args:                                                                    */
63 /*   z  - the point to calculate the depth for (vector of dimension d),     */
64 /*   xx - the data w.r.t. which the depth has to be computed, (matrix of    */
65 /*        dimension n x d)                                                  */
66 /*   n  - number of the data points,                                        */
67 /*   d  - dimension of the Euclidean space.                                 */
68 /* Returns:                                                                 */
69 /*   depth of z w.r.t. xx in the interval [0,1].                            */
70 /****************************************************************************/
71 double HD_Rec(double* z, double** xx, int n, int d);
72