npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
randomTukeyDepth.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_RANDOMTUKEYDEPTH_HH_
2 #define NPSTAT_RANDOMTUKEYDEPTH_HH_
3 
4 /*!
5 // \file randomTukeyDepth.hh
6 //
7 // \brief Implementation of Tukey depth using random directions and/or
8 // directions from the center of the cloud to the sample points
9 //
10 // Author: I. Volobouev
11 //
12 // March 2023
13 */
14 
15 #include "npstat/nm/Matrix.hh"
17 
18 // For a detailed description of the random Tukey depth concept, see
19 // Cuesta-Albertos, J. A. and Nieto-Reyes, A., "The random Tukey depth",
20 // Computational Statistics & Data Analysis 52, 11 (July 2008), 4979-4988.
21 namespace npstat {
22  /**
23  // Random Tukey depth calculated within the sample.
24  // Function arguments are as follows:
25  //
26  // sample should be dimensioned n x d, where d is the
27  // point dimensionality and n is the sample size.
28  //
29  // rng random number generator in 1 or d dimensions.
30  //
31  // covmat should be dimensioned d x d. The random directions
32  // will be generated by a multivariate normal
33  // distribution with this covariance matrix.
34  //
35  // nRandom is the number of random directions to generate.
36  // In addition to random directions, the ordering
37  // will also be perfomed according to the marginals.
38  //
39  // depth this array will be filled with depth values
40  // on exit (in the same order of points as in
41  // the "sample" argument).
42  //
43  // nDepth is the length of the "depth" array. Should be
44  // at least as large as the sample size.
45  //
46  // usePointDirections if this argument is set to "true",
47  // directions from the center of the
48  // cloud to each sample point will also
49  // be utilized in the depth calculation.
50  //
51  // The CPU time used by this function will scale as
52  // O(nRandom*n*log(n)) if "usePointDirections" is false.
53  // If "usePointDirections" is true, another step will
54  // be added that scales as O(n^2*log(n)).
55  */
56  template<typename Real>
57  void randomTukeyDepth1(const Matrix<Real>& sample,
58  AbsRandomGenerator& rng,
59  const Matrix<double>& covmat,
60  unsigned nRandom,
61  double* depth, unsigned nDepth,
62  bool usePointDirections = false);
63 
64  /**
65  // Random Tukey depth for each point in a sample calculated
66  // using another (reference) sample. Function arguments are
67  // as follows:
68  //
69  // sample should be dimensioned n x d, where d is the
70  // point dimensionality and n is the sample size.
71  //
72  // refSample the depth of each point in the "sample" argument
73  // will be defined with respect to this "reference"
74  // sample. The size of this sample should normally
75  // be substantialy larger than n.
76  //
77  // rng random number generator in 1 or d dimensions.
78  //
79  // covmat should be dimensioned d x d. The random directions
80  // will be generated by a multivariate normal
81  // distribution with this covariance matrix.
82  //
83  // nRandom is the number of random directions to generate.
84  // In addition to random directions, the ordering
85  // will also be perfomed according to the marginals.
86  //
87  // depth this array will be filled with depth values
88  // on exit (in the same order of points as in
89  // the "sample" argument).
90  //
91  // nDepth is the length of the "depth" array. Should be
92  // at least as large as the "sample" size.
93  //
94  // usePointDirections if this argument is set to "true",
95  // directions from the center of the
96  // "refSample" cloud to each point of
97  // the "sample" will also be utilized
98  // in the depth calculation.
99  //
100  // Assuming that the size of the reference sample is m,
101  // the CPU time used by this function will scale as
102  // O(nRandom*(m+n)*log(m)) if "usePointDirections" is false.
103  // If "usePointDirections" is true, another step will
104  // be added that scales as O(n*(m+n)*log(m)).
105  */
106  template<typename Real1, typename Real2>
107  void randomTukeyDepth2(const Matrix<Real1>& sample,
108  const Matrix<Real2>& refSample,
109  AbsRandomGenerator& rng,
110  const Matrix<double>& covmat,
111  unsigned nRandom,
112  double* depth, unsigned nDepth,
113  bool usePointDirections = false);
114 }
115 
116 #include "npstat/stat/randomTukeyDepth.icc"
117 
118 #endif // NPSTAT_RANDOMTUKEYDEPTH_HH_
Interface definition for pseudo- and quasi-random number generators.
Template matrix class.
Definition: Matrix.hh:49
Definition: AbsArrayProjector.hh:14
void randomTukeyDepth1(const Matrix< Real > &sample, AbsRandomGenerator &rng, const Matrix< double > &covmat, unsigned nRandom, double *depth, unsigned nDepth, bool usePointDirections=false)
void randomTukeyDepth2(const Matrix< Real1 > &sample, const Matrix< Real2 > &refSample, AbsRandomGenerator &rng, const Matrix< double > &covmat, unsigned nRandom, double *depth, unsigned nDepth, bool usePointDirections=false)
Definition: AbsRandomGenerator.hh:27