npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
WeightedLTSLoss.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_WEIGHTEDLTSLOSS_HH_
2 #define NPSTAT_WEIGHTEDLTSLOSS_HH_
3 
4 /*!
5 // \file WeightedLTSLoss.hh
6 //
7 // \brief Loss function for local least trimmed squares with one excluded point
8 //
9 // Author: I. Volobouev
10 //
11 // December 2011
12 */
13 
14 #include "npstat/nm/OrthoPolyND.hh"
17 
18 namespace npstat {
19  /**
20  // Calculator of windowed least trimmed squares for use with gridded
21  // robust regression. The chi-squared is calculated for the whole window
22  // with the central point excluded. The loss improvement is estimated only
23  // for the point in the window center.
24  //
25  // Template parameters MaxDim and MaxReplace are just like those in
26  // griddedRobustRegression.hh. For use with this particular loss
27  // calculator, MaxReplace value of 1 is the most appropriate. Template
28  // parameter MaxDeg is the maximum local polynomial degree.
29  */
30  template <unsigned MaxDim, unsigned MaxReplace, unsigned MaxDeg>
31  class WeightedLTSLoss : public AbsLossCalculator<MaxDim,MaxReplace>
32  {
33  public:
35 
36  /**
37  // "weight" is the function used to generate local polynomials.
38  // It will be called on the local window using window coordinate
39  // system. For example, the point in the window center will be
40  // at the origin, and coordinates of all points neighboring the
41  // origin in each dimension will be either 0 or 1. The weight
42  // therefore must have an appropriate bandwidth, consistent
43  // with the expected local window width. If the bandwidth is
44  // too small (weight on the edges of the window is exactly 0)
45  // then the code will still work but will be inefficient.
46  //
47  // "deg" is the actual degree of these polynomials (must not
48  // exceed "maxdeg").
49  */
50  inline WeightedLTSLoss(const AbsDistributionND& weight, unsigned deg)
51  : weightFcn_(weight.clone()), polys_(0), degree_(deg) {}
52 
53  virtual ~WeightedLTSLoss();
54 
56  const ArrayND<double>& slidingWindow,
57  const unsigned* indexInWindow,
58  const unsigned* indexInDataset,
59  BlockReplacement* block) const;
60 
61  private:
62  typedef OrthoPolyND<MaxDeg> Poly;
63 
65  WeightedLTSLoss& operator=(const WeightedLTSLoss&);
66 
67  void initialize(const ArrayND<double>& in);
68 
69  AbsDistributionND* weightFcn_;
70  ArrayND<Poly*>* polys_;
71  mutable std::vector<double> coeffs_;
72  unsigned degree_;
73  };
74 }
75 
76 #include "npstat/stat/WeightedLTSLoss.icc"
77 
78 #endif // NPSTAT_WEIGHTEDLTSLOSS_HH_
Interface definition for multivariate continuous statistical distributions.
Interfaces and utility classes for gridded robust regression.
Discrete orthogonal polynomial series of arbitrary dimensionality in hyperrectangular domains.
Definition: AbsDistributionND.hh:26
Definition: OrthoPolyND.hh:28
Definition: WeightedLTSLoss.hh:32
WeightedLTSLoss(const AbsDistributionND &weight, unsigned deg)
Definition: WeightedLTSLoss.hh:50
virtual LocalLoss operator()(const ArrayND< double > &slidingWindow, const unsigned *indexInWindow, const unsigned *indexInDataset, BlockReplacement *block) const
Definition: AbsArrayProjector.hh:14
Definition: AbsLossCalculator.hh:95
Definition: AbsLossCalculator.hh:23
Definition: AbsLossCalculator.hh:57