|
STK++ 1.0
|
00001 /*--------------------------------------------------------------------*/ 00002 /* Copyright (C) 2004-2007 Serge Iovleff 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as 00006 published by the Free Software Foundation; either version 2 of the 00007 License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public 00015 License along with this program; if not, write to the 00016 Free Software Foundation, Inc., 00017 59 Temple Place, 00018 Suite 330, 00019 Boston, MA 02111-1307 00020 USA 00021 00022 Contact : Serge.Iovleff@stkpp.org 00023 */ 00024 00025 /* 00026 * Project: stkpp::AAModels 00027 * created on: 17 avr. 2010 00028 * Purpose: Implementation of the Index class using the local variance. 00029 * Author: iovleff, serge.iovleff@stkpp.org 00030 **/ 00031 00036 #ifndef STK_LOCALVARIANCE_H 00037 #define STK_LOCALVARIANCE_H 00038 00039 #include "STK_ILinearReduct.h" 00040 00041 #include "../../Arrays/include/STK_MatrixSquare.h" 00042 00043 #include "../../STatistiK/include/STK_Stat_MultivariateReal.h" 00044 00045 namespace STK 00046 { 00047 00057 class LocalVariance : public ILinearReduct 00058 { 00059 public: 00066 enum TypeGraph { prim_, minimalDistance_, unknown_ }; 00067 00073 static TypeGraph StringToTypeGraph( String const& type); 00074 00079 static String TypeGraphToString( TypeGraph const& type); 00080 00087 LocalVariance( Matrix const& data 00088 , TypeGraph const& type = minimalDistance_ 00089 , Integer const& nbNeighbor =1 00090 ); 00091 00093 virtual ~LocalVariance(); 00094 00099 inline Integer const& nbNeighbor() const { return nbNeighbor_;} 00104 inline Array2D<Integer> const& pred() const { return neighbors_;} 00109 inline MatrixSquare const& covariance() const { return covariance_;} 00115 inline MatrixSquare const& localCovariance() const { return *p_localCov_;} 00116 00117 protected: 00121 virtual void update(); 00122 00124 TypeGraph type_; 00126 Integer nbNeighbor_; 00129 Array2D<Integer> neighbors_; 00131 Matrix dist_; 00132 00134 MatrixSquare * p_localCov_; 00136 MatrixSquare covariance_; 00140 Stat::MultivariateMatrix* p_dataStatistics_; 00141 00146 virtual void maximizeIndex(); 00147 00153 virtual void maximizeIndex( Vector const& weights); 00154 00156 void prim(); 00158 void minimalDistance(); 00159 00161 void computeCovarianceMatrices(); 00163 void computeCovarianceMatrices( Vector const& weights); 00164 00165 private: 00169 void computeAxis(); 00170 00172 void initializeMemory(); 00174 void clear(); 00175 }; 00176 00177 } // namespace STK 00178 #endif /* STK_LOCALVARIANCE_H */