00001 /*!@file Util/stats.H STATS classes */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: T Nathan Mundhenk <mundhenk@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Util/stats.H $ 00035 // $Id: stats.H 4663 2005-06-23 17:47:28Z rjpeters $ 00036 // 00037 00038 00039 // ############################################################ 00040 // ############################################################ 00041 // ##### ---STATS--- 00042 // ##### Some basic statistical methods: 00043 // ##### T. Nathan Mundhenk nathan@mundhenk.com 00044 // ############################################################ 00045 // ############################################################ 00046 00047 #ifndef STATS_H_DEFINED 00048 #define STATS_H_DEFINED 00049 00050 #include "Util/Assert.H" 00051 00052 #include <vector> 00053 00054 template <class T> class stats 00055 { 00056 private: 00057 public: 00058 //! Constructor 00059 stats(); 00060 //! Destructor 00061 ~stats(); 00062 //! some bools for ASSERTION testing 00063 bool GGC; 00064 //basic holders for conveniance 00065 //! X bar - the population mean for x 00066 T Xb; 00067 //! Y bar - the population mean for y 00068 T Yb; 00069 //! S squared - population measure for variance 00070 T S2; 00071 //! S - population measure for varaince 00072 T Sx,Sy,S; 00073 //! r - the corralation coefficent 00074 T r; 00075 //! b - the regression coefficent slope 00076 T b; 00077 //! probability of A or B 00078 T PA, PB; 00079 //! decision boundrys 00080 T D, Dprime; 00081 //! SStotal, SSwithin, SSbetween 00082 T SStotal, SSwithin, SSbetween, DFwithin, DFbetween, MSwithin, MSbetween, F; 00083 //! The populational mean 00084 T mean(std::vector<T> &X); 00085 //! The standard deviation of the population 00086 T findS(std::vector<T> &X, T Xbar); 00087 //! The standard deviation of the population, adjust for negative numbers 00088 T findS(std::vector<T> &X, T Xbar, T adj); 00089 //! basic pearson r linear regression 00090 T rRegression(std::vector<T> &X, std::vector<T> &Y); 00091 //! regression coefficent slope 00092 /*! This can be use to fit the line of regression as 00093 Y' = b*(X - Xbar) + YBar 00094 */ 00095 T bRegression(std::vector<T> &X, std::vector<T> &Y); 00096 //! raw score regression coefficent 00097 /*! This can be use to fit the line of regression as 00098 Y' = Bxy*(X - Xbar) + YBar 00099 */ 00100 T Bxy(T r, T Sx, T Sy); 00101 //! This is a simple ANOVA for two groups 00102 /*! input the raw scores for the two groups, let it run 00103 will run on assumption of SStotal = SSwithin + SSbetween 00104 */ 00105 T simpleANOVA(std::vector<T> &X, std::vector<T> &Y); 00106 //! find the decision boundry as described in Itti(2000) PhD Thesis pg. 145-8 00107 /*! Find a decision in the general gaussian case 00108 input mu's sigma's and P(X)'s for two events. This will return D. Use 00109 getDPrime() to get D' following this command. 00110 @param mu1 mean for condition 1 00111 @param mu2 mean for condition 2 00112 @param sigma1 std dev for condition 1 00113 @param sigma2 std dev for condition 2 00114 @param PofA probability of A (0 to 1) PofB is determined as 1 - PofA 00115 */ 00116 T decisionGGC(T mu1, T mu2, T sigma1, T sigma2, T PofA); 00117 //! Return D' after running descisionGGC 00118 T getDPrime(); 00119 //! Get the probability of Error for a 2AFC paradigm 00120 /*! take the decision boundrys and find the probability of error 00121 from them. This is for Two Alternative forced choice paradigm 00122 @param mu1 mean for condition 1 00123 @param mu2 mean for condition 2 00124 @param sigma1 std dev for condition 1 00125 @param sigma2 std dev for condition 2 00126 @param PofA probability of A (0 to 1) PofB is determined as 1 - PofA 00127 */ 00128 T getErrorGGC_2AFC(T mu1, T mu2, T sigma1, T sigma2); 00129 //! return the gaussian from f(x;mu,sigma) = guassian 00130 /*! Return a simple P(x) based upon the gaussian distribution with an 00131 input sample x and gaussian defined with mu as E(x) and sigma as 00132 E(x^2) 00133 */ 00134 T gauss(T x, T mu,T sigma); 00135 00136 }; 00137 00138 // ###################################################################### 00139 /* So things look consistent in everyone's emacs... */ 00140 /* Local Variables: */ 00141 /* indent-tabs-mode: nil */ 00142 /* End: */ 00143 00144 #endif