R: Compute the 'Amari' distance between two matrices
amari
R Documentation
Compute the 'Amari' distance between two matrices
Description
The Amari distance is a measure between two nonsingular matrices. Useful for
checking for convergence in ICA algorithms, and for comparing solutions.
Usage
amari(V, W, orth = FALSE)
Arguments
V
first matrix
W
second matrix
orth
are the matrices orthogonal; default is orth=FALSE
Details
Formula is given in second reference below, page 570.
Value
a numeric distance metween 0 and 1
Author(s)
Trevor Hastie
References
Bach, F. and Jordan, M. (2002). Kernel independent component analysis,
Journal of Machine Learning Research 3: 1-48
Hastie, T., Tibshirani, R. and Friedman, J. (2009) Elements of
Statistical Learning (2nd edition), Springer. http://www-stat.stanford.edu/~hastie/Papers/ESLII.pdf
See Also
ProDenICA
Examples
dist="n"
N=1024
p=2
A0<-mixmat(p)
s<-scale(cbind(rjordan(dist,N),rjordan(dist,N)))
x <- s %*% A0
###Whiten the data
x <- scale(x, TRUE, FALSE)
sx <- svd(x) ### orthogonalization function
x <- sqrt(N) * sx$u
target <- solve(A0)
target <- diag(sx$d) %*% t(sx$v) %*% target/sqrt(N)
W0 <- matrix(rnorm(2*2), 2, 2)
W0 <- ICAorthW(W0)
W1 <- ProDenICA(x, W0=W0,trace=TRUE,Gfunc=G1)$W
fit=ProDenICA(x, W0=W0,Gfunc=GPois,trace=TRUE, density=TRUE)
W2 <- fit$W
#distance of FastICA from target
amari(W1,target)
#distance of ProDenICA from target
amari(W2,target)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(ProDenICA)
Loading required package: gam
Loading required package: splines
Loading required package: foreach
Loaded gam 1.12
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ProDenICA/amari.Rd_%03d_medium.png", width=480, height=480)
> ### Name: amari
> ### Title: Compute the 'Amari' distance between two matrices
> ### Aliases: amari
> ### Keywords: multivariate
>
> ### ** Examples
>
> dist="n"
> N=1024
> p=2
> A0<-mixmat(p)
> s<-scale(cbind(rjordan(dist,N),rjordan(dist,N)))
> x <- s %*% A0
> ###Whiten the data
> x <- scale(x, TRUE, FALSE)
> sx <- svd(x) ### orthogonalization function
> x <- sqrt(N) * sx$u
> target <- solve(A0)
> target <- diag(sx$d) %*% t(sx$v) %*% target/sqrt(N)
> W0 <- matrix(rnorm(2*2), 2, 2)
> W0 <- ICAorthW(W0)
> W1 <- ProDenICA(x, W0=W0,trace=TRUE,Gfunc=G1)$W
Iter 1 G 0.3762347 crit 0.1537012
Iter 2 G 0.3761222 crit 0.08628485
Iter 3 G 0.3761717 crit 0.1100507
Iter 4 G 0.376113 crit 0.1001546
Iter 5 G 0.3761644 crit 0.1047464
Iter 6 G 0.3761114 crit 0.1029682
Iter 7 G 0.3761631 crit 0.1038262
Iter 8 G 0.3761111 crit 0.103499
Iter 9 G 0.3761629 crit 0.103658
Iter 10 G 0.376111 crit 0.1035976
Iter 11 G 0.3761629 crit 0.103627
Iter 12 G 0.376111 crit 0.1036158
Iter 13 G 0.3761628 crit 0.1036212
Iter 14 G 0.376111 crit 0.1036192
Iter 15 G 0.3761628 crit 0.1036202
Iter 16 G 0.376111 crit 0.1036198
Iter 17 G 0.3761628 crit 0.10362
Iter 18 G 0.376111 crit 0.1036199
Iter 19 G 0.3761628 crit 0.1036199
Iter 20 G 0.376111 crit 0.1036199
Iter 21 G 0.3761628 crit 0.1036199
> fit=ProDenICA(x, W0=W0,Gfunc=GPois,trace=TRUE, density=TRUE)
Iter 1 G 0.02227652 crit 0.04740158
Iter 2 G 0.0231778 crit 0.009062331
Iter 3 G 0.02326334 crit 0.001627743
Iter 4 G 0.02324134 crit 0.0004278
Iter 5 G 0.02323232 crit 1.955837e-05
Iter 6 G 0.02323071 crit 9.771971e-06
Iter 7 G 0.02322848 crit 3.236821e-05
Iter 8 G 0.02323007 crit 2.425095e-06
Iter 9 G 0.02323008 crit 1.21645e-07
Iter 10 G 0.02323008 crit 5.772103e-09
> W2 <- fit$W
> #distance of FastICA from target
> amari(W1,target)
[1] 0.2493955
> #distance of ProDenICA from target
> amari(W2,target)
[1] 0.006857558
>
>
>
>
>
> dev.off()
null device
1
>