npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
orthoPoly1DVProducts.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_ORTHOPOLY1DVPRODUCTS_HH_
2 #define NPSTAT_ORTHOPOLY1DVPRODUCTS_HH_
3 
4 /*!
5 // \file orthoPoly1DVProducts.hh
6 //
7 // \brief Utility functions for calculating statistical properties of
8 // 1-d orthogonal polynomials
9 //
10 // Author: I. Volobouev
11 //
12 // September 2017
13 */
14 
15 #include "npstat/nm/ArrayND.hh"
18 
19 namespace npstat {
20  // See the "Empirical Chaos Polynomials" write-up for the
21  // definition of v_{ab} and various related formulae for
22  // expectations and covariances
23  template <class Quadrature>
24  double expectedVProduct(const AbsClassicalOrthoPoly1D& poly,
25  const Quadrature& quad, unsigned long nPoints,
26  UUPair ab, UUPair cd);
27 
28  template <class Quadrature>
29  double expectedVProduct(const AbsClassicalOrthoPoly1D& poly,
30  const Quadrature& quad, unsigned long nPoints,
31  UUPair ab, UUPair cd, UUPair ef);
32 
33  template <class Quadrature>
34  double expectedVProduct(const AbsClassicalOrthoPoly1D& poly,
35  const Quadrature& quad, unsigned long nPoints,
36  UUPair ab, UUPair cd, UUPair ef, UUPair gh);
37 
38  // Covariance between v_{ab} and v_{cd}
39  template <class Quadrature>
40  double expectedVCovariance(const AbsClassicalOrthoPoly1D& poly,
41  const Quadrature& quad, unsigned long nPoints,
42  UUPair ab, UUPair cd);
43 
44  // Covariance between v_{ab}*v_{cd} and v_{ef}
45  template <class Quadrature>
46  double expectedVCovariance(const AbsClassicalOrthoPoly1D& poly,
47  const Quadrature& quad, unsigned long nPoints,
48  UUPair ab, UUPair cd, UUPair ef);
49 
50  // Covariance between v_{ab}*v_{cd} and v_{ef}*v_{gh}
51  template <class Quadrature>
52  double expectedVCovariance(const AbsClassicalOrthoPoly1D& poly,
53  const Quadrature& quad, unsigned long nPoints,
54  UUPair ab, UUPair cd, UUPair ef, UUPair gh);
55 
56  // Covariance of sample covariance between v_{ab} and v_{cd}
57  template <class Quadrature>
58  double expectedVCovCov(const AbsClassicalOrthoPoly1D& poly,
59  const Quadrature& quad, unsigned long nPoints,
60  UUPair ab, UUPair cd, UUPair ef, UUPair gh);
61 
62  // v_{ab} calculated for a given sample of unweighted points.
63  // For samples generated using the polynomial weight function
64  // as the density, the expectation value of v_{ab} is 0.
65  template <typename Numeric>
66  double sampleVProduct(const AbsClassicalOrthoPoly1D& poly,
67  const Numeric* coords, unsigned long nCoords,
68  UUPair ab);
69 
70  // v_{ab}*v_{cd} calculated for a given sample of unweighted points
71  template <typename Numeric>
72  double sampleVProduct(const AbsClassicalOrthoPoly1D& poly,
73  const Numeric* coords, unsigned long nCoords,
74  UUPair ab, UUPair cd);
75 
76  // v_{ab}*v_{cd}*v_{ef} calculated for a given sample
77  template <typename Numeric>
78  double sampleVProduct(const AbsClassicalOrthoPoly1D& poly,
79  const Numeric* coords, unsigned long nCoords,
80  UUPair ab, UUPair cd, UUPair ef);
81 
82  // v_{ab}*v_{cd}*v_{ef}*v_{gh} calculated for a given sample
83  template <typename Numeric>
84  double sampleVProduct(const AbsClassicalOrthoPoly1D& poly,
85  const Numeric* coords, unsigned long nCoords,
86  UUPair ab, UUPair cd, UUPair ef, UUPair gh);
87 
88  // Expectation of v_{ab}*v_{cd} using sample averages of oracle polys
89  template <typename Numeric>
90  double sampleVProductExp(const AbsClassicalOrthoPoly1D& poly,
91  const Numeric* coords, unsigned long nCoords,
92  UUPair ab, UUPair cd);
93 
94  // Expectation of v_{ab}*v_{cd}*v_{ef} using sample averages
95  // of oracle polys
96  template <typename Numeric>
97  double sampleVProductExp(const AbsClassicalOrthoPoly1D& poly,
98  const Numeric* coords, unsigned long nCoords,
99  UUPair ab, UUPair cd, UUPair ef);
100 
101  // Expectation of v_{ab}*v_{cd}*v_{ef}*v_{gh} using sample averages
102  // of oracle polys
103  template <typename Numeric>
104  double sampleVProductExp(const AbsClassicalOrthoPoly1D& poly,
105  const Numeric* coords, unsigned long nCoords,
106  UUPair ab, UUPair cd, UUPair ef, UUPair gh);
107 
108  // Covariance between v_{ab} and v_{cd} estimated using
109  // polynomial averages taken from the given sample
110  template <typename Numeric>
111  double sampleVCovariance(const AbsClassicalOrthoPoly1D& poly,
112  const Numeric* coords, unsigned long nCoords,
113  UUPair ab, UUPair cd);
114 
115  // Fill a 4-d array with "v_{mn}" covariances estimated from the sample.
116  // The code knows that the covariances are symmetric with respect to
117  // permuting some indices, and does not recalculate them when permuting
118  // indices is sufficient. The array span will be maxdeg+1 in each
119  // dimension.
120  template <typename Numeric>
121  ArrayND<double> sampleVCovarianceArray(
122  const AbsClassicalOrthoPoly1D& poly, const Numeric* coords,
123  unsigned long nCoords, unsigned maxdeg);
124 
125  // Covariance between v_{ab}*v_{cd} and v_{ef} estimated using
126  // polynomial averages taken from the given sample
127  template <typename Numeric>
128  double sampleVCovariance(const AbsClassicalOrthoPoly1D& poly,
129  const Numeric* coords, unsigned long nCoords,
130  UUPair ab, UUPair cd, UUPair ef);
131 
132  // Covariance between v_{ab}*v_{cd} and v_{ef}*v_{gh} estimated
133  // using polynomial averages taken from the given sample
134  template <typename Numeric>
135  double sampleVCovariance(const AbsClassicalOrthoPoly1D& poly,
136  const Numeric* coords, unsigned long nCoords,
137  UUPair ab, UUPair cd, UUPair ef, UUPair gh);
138 
139  // Covariance of sample covariance between v_{ab} and v_{cd} estimated
140  // using polynomial averages taken from the given sample
141  template <typename Numeric>
142  double sampleVCovCov(const AbsClassicalOrthoPoly1D& poly,
143  const Numeric* coords, unsigned long nCoords,
144  UUPair ab, UUPair cd, UUPair ef, UUPair gh);
145 
146  // Oracle counterpart of the "epsExpectation" method of the
147  // ContOrthoPoly1D class. If "highOrder" parameter is "true",
148  // the calculations will be performed to O(N^{-3/2}). If "highOrder"
149  // is "false", the calculations will be to O(N^{-1}).
150  template <class Quadrature>
151  double oracleEpsExpectation(const AbsClassicalOrthoPoly1D& poly,
152  const Quadrature& quad, unsigned long nPoints,
153  unsigned m, unsigned n, bool highOrder);
154 
155  // Oracle counterpart of the "epsCovariance" method of the
156  // ContOrthoPoly1D class
157  template <class Quadrature>
158  double oracleEpsCovariance(const AbsClassicalOrthoPoly1D& poly,
159  const Quadrature& quad, unsigned long nPoints,
160  unsigned m1, unsigned n1,
161  unsigned m2, unsigned n2, bool highOrder);
162 
163  // Fill a 4-d array with oracle "eps_{mn}" covariances. The code knows
164  // that the covariances are symmetric with respect to permuting some
165  // indices, and does not recalculate them when permuting indices is
166  // sufficient. The array span will be maxdeg+1 in each dimension.
167  template <class Quadrature>
168  ArrayND<double> oracleEpsCovarianceArray(
169  const AbsClassicalOrthoPoly1D& poly, const Quadrature& quad,
170  unsigned long nPoints, unsigned maxdeg, bool highOrder);
171 
172  // Calculate the "eps_{mn}" approximation for a given sample
173  // of unweighted points (up to O(N^{-1}) or O(N^{-3/2})). In
174  // this approximation, all v_{ij} values are calculated using
175  // sample averages of oracle polynomials. Note that the result
176  // is not the exact "eps_{mn}" for the sample but just this
177  // particular special approximation.
178  template <typename Numeric>
179  double sampleEpsValue(const AbsClassicalOrthoPoly1D& poly,
180  const Numeric* coords, unsigned long nCoords,
181  unsigned m, unsigned n, bool highOrder);
182 
183  // Counterpart of the "epsExpectation" method of the ContOrthoPoly1D
184  // class in which chaos polys are replaced by oracle polys. It is useful
185  // for checking the effect of replacing the empirical polys with the
186  // oracle ones in the "eps_{mn}" approximation.
187  template <typename Numeric>
188  double sampleEpsExpectation(const AbsClassicalOrthoPoly1D& poly,
189  const Numeric* coords, unsigned long nCoords,
190  unsigned m, unsigned n, bool highOrder);
191 
192  // eps_{mn} covariance approximation using polynomial product
193  // averages from the given sample of points
194  template <typename Numeric>
195  double sampleEpsCovariance(const AbsClassicalOrthoPoly1D& poly,
196  const Numeric* coords, unsigned long nCoords,
197  unsigned m1, unsigned n1,
198  unsigned m2, unsigned n2, bool highOrder);
199 
200  // Fill a 4-d array with "eps_{mn}" covariances estimated from the sample.
201  // The code knows that the covariances are symmetric with respect to
202  // permuting some indices, and does not recalculate them when permuting
203  // indices is sufficient. The array span will be maxdeg+1 in each
204  // dimension.
205  template <typename Numeric>
206  ArrayND<double> sampleEpsCovarianceArray(
207  const AbsClassicalOrthoPoly1D& poly, const Numeric* coords,
208  unsigned long nCoords, unsigned maxdeg, bool highOrder);
209 }
210 
211 #include "npstat/stat/orthoPoly1DVProducts.icc"
212 
213 #endif // NPSTAT_ORTHOPOLY1DVPRODUCTS_HH_
Base class for classical continuous orthonormal polynomials.
Arbitrary-dimensional array template.
Utility for enumerating pairs on diagonals of symmetric matrices.
Definition: AbsArrayProjector.hh:14