00001 // $Id: LDA.h 29195 2009-06-24 10:39:49Z brun $ 00002 /********************************************************************************** 00003 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * 00004 * Package: TMVA * 00005 * Class : LDA * 00006 * Web : http://tmva.sourceforge.net * 00007 * * 00008 * Description: * 00009 * Local LDA method used by MethodKNN to compute MVA value. * 00010 * This is experimental code under development. This class computes * 00011 * parameters of signal and background PDFs using Gaussian aproximation. * 00012 * * 00013 * Author: * 00014 * John Alison John.Alison@cern.ch - University of Pennsylvania, USA * 00015 * * 00016 * Copyright (c) 2007: * 00017 * CERN, Switzerland * 00018 * MPI-K Heidelberg, Germany * 00019 * University of Pennsylvania, USA * 00020 * * 00021 * Redistribution and use in source and binary forms, with or without * 00022 * modification, are permitted according to the terms listed in LICENSE * 00023 * (http://tmva.sourceforge.net/LICENSE) * 00024 **********************************************************************************/ 00025 00026 #ifndef ROOT_TMVA_LDA 00027 #define ROOT_TMVA_LDA 00028 00029 00030 // C/C++ 00031 #include <map> 00032 #include <vector> 00033 00034 // ROOT 00035 #ifndef ROOT_Rtypes 00036 #include "Rtypes.h" 00037 #endif 00038 #ifndef ROOT_TMatrixFfwd 00039 #include "TMatrixFfwd.h" 00040 #endif 00041 00042 typedef std::vector<std::vector<Float_t> > LDAEvents; 00043 00044 namespace TMVA { 00045 00046 class MsgLogger; 00047 00048 class LDA { 00049 00050 public: 00051 00052 LDA(Float_t tolerence = 1.0e-5, Bool_t debug = false); 00053 ~LDA(); 00054 00055 // Signal probability with Gaussian approximation 00056 Float_t GetProb(const std::vector<Float_t>& x, Int_t k); 00057 00058 // Log likelihood function with Gaussian approximation 00059 Float_t GetLogLikelihood(const std::vector<Float_t>& x, Int_t k); 00060 00061 // Create LDA matrix using local events found by knn method 00062 void Initialize(const LDAEvents& inputSignal, const LDAEvents& inputBackground); 00063 00064 private: 00065 00066 // Probability value using Gaussian approximation 00067 Float_t FSub(const std::vector<Float_t>& x, Int_t k); 00068 00069 MsgLogger& Log() const { return *fLogger; } 00070 00071 private: 00072 00073 // data members 00074 Float_t fTolerence; // documentation! 00075 UInt_t fNumParams; // documentation! 00076 std::map<Int_t, std::vector<Float_t> > fMu; // documentation! 00077 TMatrixF* fSigma; // documentation! 00078 TMatrixF* fSigmaInverse; // documentation! 00079 std::map<Int_t, Float_t> fEventFraction; // documentation! 00080 Bool_t fDebug; // documentation! 00081 00082 mutable MsgLogger *fLogger; // message logging service 00083 }; 00084 } 00085 #endif