ROOT logo
// @(#)root/gl:$Id: TKDEFGT.h 28589 2009-05-13 06:48:00Z brun $
// Author: Timur Pocheptsov  2009
/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TKDEFGT
#define ROOT_TKDEFGT

#include <vector>

#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif

//KDE - kenrel density estimator,
//based on fast Gauss transform.


class TKDEFGT {
private:
   //KDE-related stuff.   
   std::vector<Double_t>   fXC;     //Centers.
   std::vector<Double_t>   fWeights;//Weights.
   std::vector<Int_t>      fIndxc;  //Internal data.
   std::vector<Double_t>   fA_K;    //Polynomial coefficient (pd x K)
   std::vector<Int_t>      fIndx;   //Internal data.
   std::vector<Int_t>      fXhead;  //Internal data.
   std::vector<Int_t>      fXboxsz; //Internal data.
   std::vector<Double_t>   fDistC;  //Internal data.
   std::vector<Double_t>   fC_K;    //Internal data.
   std::vector<Int_t>      fCinds;  //Internal data.
   
   mutable std::vector<Int_t>      fHeads; //Internal data.
   mutable std::vector<Double_t>   fDx;    //Internal data.
   mutable std::vector<Double_t>   fProds; //Internal data.
   
   Int_t                   fDim;        //Number of dimensions.
   Int_t                   fP;          //Order of trancation.
   Int_t                   fK;          //Number of centers.
   Double_t                fSigma;      //Noise Standard deviation of the kernel (default sigma = 1)
   Int_t                   fPD;         //nchoosek(fP + fDim - 1, fDim); 
   Bool_t                  fModelValid; //Check, if coefficients are ok.
   Bool_t                  fVerbose;
   
public:
   TKDEFGT();
   
   virtual ~TKDEFGT();
   
   //Sources and targets must be a vector of packed points, if you have, say,
   //Dim == 3, vector will be [xyz|xyz|xyz|xyz|xyz].
   void BuildModel(const std::vector<Double_t> &sources, Double_t sigma = 1.,
                   Int_t dim = 3, Int_t p = 8, Int_t k = 0);
   void Predict(const std::vector<Double_t> &targets, std::vector<Double_t> &densities,
                Double_t e)const;
                
   void SetVerbose(Bool_t v) {fVerbose = v;}
private:
   void Kcenter(const std::vector<double> &x);
   void Compute_C_k();
   void Compute_A_k(const std::vector<Double_t> &x);

   TKDEFGT(const TKDEFGT &rhs);
   TKDEFGT &operator = (const TKDEFGT &rhs);
   
   ClassDef(TKDEFGT, 0)//FGT based kernel density estimator.
};

#endif
 TKDEFGT.h:1
 TKDEFGT.h:2
 TKDEFGT.h:3
 TKDEFGT.h:4
 TKDEFGT.h:5
 TKDEFGT.h:6
 TKDEFGT.h:7
 TKDEFGT.h:8
 TKDEFGT.h:9
 TKDEFGT.h:10
 TKDEFGT.h:11
 TKDEFGT.h:12
 TKDEFGT.h:13
 TKDEFGT.h:14
 TKDEFGT.h:15
 TKDEFGT.h:16
 TKDEFGT.h:17
 TKDEFGT.h:18
 TKDEFGT.h:19
 TKDEFGT.h:20
 TKDEFGT.h:21
 TKDEFGT.h:22
 TKDEFGT.h:23
 TKDEFGT.h:24
 TKDEFGT.h:25
 TKDEFGT.h:26
 TKDEFGT.h:27
 TKDEFGT.h:28
 TKDEFGT.h:29
 TKDEFGT.h:30
 TKDEFGT.h:31
 TKDEFGT.h:32
 TKDEFGT.h:33
 TKDEFGT.h:34
 TKDEFGT.h:35
 TKDEFGT.h:36
 TKDEFGT.h:37
 TKDEFGT.h:38
 TKDEFGT.h:39
 TKDEFGT.h:40
 TKDEFGT.h:41
 TKDEFGT.h:42
 TKDEFGT.h:43
 TKDEFGT.h:44
 TKDEFGT.h:45
 TKDEFGT.h:46
 TKDEFGT.h:47
 TKDEFGT.h:48
 TKDEFGT.h:49
 TKDEFGT.h:50
 TKDEFGT.h:51
 TKDEFGT.h:52
 TKDEFGT.h:53
 TKDEFGT.h:54
 TKDEFGT.h:55
 TKDEFGT.h:56
 TKDEFGT.h:57
 TKDEFGT.h:58
 TKDEFGT.h:59
 TKDEFGT.h:60
 TKDEFGT.h:61
 TKDEFGT.h:62
 TKDEFGT.h:63
 TKDEFGT.h:64
 TKDEFGT.h:65
 TKDEFGT.h:66
 TKDEFGT.h:67
 TKDEFGT.h:68
 TKDEFGT.h:69
 TKDEFGT.h:70
 TKDEFGT.h:71
 TKDEFGT.h:72
 TKDEFGT.h:73
 TKDEFGT.h:74