################################################################################ # File: ReadMe.txt # Aim : A brief introduction about the usage for Chen songxi's method and Chen songxi's method under Gauss Kernel #------------------------------------------------------------------------------- # Author: Yuan Huili (Peking University) # Email : hlyuan@pku.edu.cn # Date : 05/29/2015 #------------------------------------------------------------------------------- # Files needed: # SXvsKerSX.R # Function parameter description: # function: SXCHEN # input: # n1 ------ the number of samples in class 1 # n2 ------ the number of samples in class 2 # X1 ------ n1xp data matrix, row is sample, col is variable # X2 ------ n2xp data matrix, row is sample, col is variable # output: a numeric value # SXCHEN--- the difference of two covariance matrices under Frobenius norm # function: GSXCHEN # input: # n1 ------ the number of samples in class 1 # n2 ------ the number of samples in class 2 # X1 ------ n1xp data matrix, row is sample, col is variable # X2 ------ n2xp data matrix, row is sample, col is variable # coef ------ the parameter in Gauss kernel # output: a numeric value # GSXCHEN--- the difference of two covariance operators under Hilbert-Schmidt norm #------------------------------------------------------------------------------- # Basic example # source("SXvsKerSX.R"); # 1. generate two classes of samples generate<-function(theta,m,p) { Z<-matrix(0,nrow=m,ncol=p) for(j in 1:m) { for(k in 1:p) { Z[j,k]<-rnorm(1,0,1) } } X<-matrix(0,nrow=m,ncol=p) for(j in 1:m) { for(k in 1:(p-1)) { X[j,k]<-exp(Z[j,k])*theta*exp(Z[j,k+1]) } X[j,p]<-exp(Z[j,p])*theta*exp(Z[j,1]) } generate<-X } m<-50 n<-50 p<-50 threshold<-0.1 library(MASS) X<-generate(0.5,m,p) Y<-generate(0.2,m,p) # 2. run SXCHEN sxchen<-SXCHEN(m,n,t(X),t(Y)) # 3. run GSXCHEN gsxchen<-GSXCHEN(m,n,t(X),t(Y),10) # 4. if(sxchen>threshold) print("The two covariance matrices are different under Frobenius norm.") if(sxchen<=threshold) print("The two covariance matrices are the same under Frobenius norm.") if(gsxchen>threshold) print("The two covariance operators are different under Hilbert-Schmidt norm.") if(gsxchen<=threshold) print("The two covariance operators are the same under Hilbert-Schmidt norm.") #-------------------------------------------------------------------------------