Independent component Analysis (ICA) simulation Experiment (R language)

Source: Internet
Author: User

This note is a simulation of the ESL14.7 section, figure 14.42. The first part will take the ProDenICA law as an example to try to introduce the whole process of ICA, the second part will compare ProDenICA , FastICA and KernelICA This method, try to reproduce figure 14.42.

ICA's simulation process generates data

First we have to have a set of independent (ICA prerequisites) distributed Data \ (s\)(unknown), and then after the Matrix \ (a_0\) mixed to get the actual observations \ (x\), that is,

\[x= Sa_0\]

can also be written
\[s=xa_0^{-1}\]

In the case of cocktail receptions, the voices from different individuals are mixed with microphones to get the signals we actually receive. Suppose there are two separate sets of data, the distribution is n (corresponding to the number in Figure 14.42), each group of data is \ (n=1024\), the mixed matrix is A0 , with R code describes the process as follows

library(ProDenICA)p = 2dist = "n" N = 1024A0 = mixmat(p)s = scale(cbind(rjordan(dist,N),rjordan(dist,N)))x = s %*% A0

Finally we get the observed values x .

Albino

In the case of ICA, which is the hybrid matrix \ (\MATHBF a\)in recovery \ (X=S\MATHBF a\ ), it is assumed that \ (x\) has been albino ( \mathrm{cov} (X) =\MATHBF i\), and this process can be achieved using SVD. For centralized \ (x\), according to

\[x=\mathbf{udv}^t= \SQRT{N}\MATHBF U\frac{1}{\sqrt{n}}\mathbf{dv}^t=x^*\frac{1}{\sqrt{n}}\mathbf{dv}^t\]

( Cov (x^*) =\mathbf i\) \ (x^*\), then

\[s=xa_0^{-1}=x^*dv^ta_0^{-1}/\sqrt{n}\]

So after this transformation, the mixed matrix becomes

\[a = dv^ta_0^{-1}/\sqrt{n}\]

The
\[x^*=sa^t\]

The following is indicated in the R language

x <- scale(x, TRUE, FALSE) # centralsx <- svd(x)    x <- sqrt(N) * sx$u # satisfy cov(x) = Itarget <- solve(A0)target <- diag(sx$d) %*% t(sx$v) %*% target/sqrt(N) # new mixing maxtrix
ProDenICAMethod

Details are no longer expanded and are calculated directly using ProDenICA the packages in

W0 <- matrix(rnorm(2*2), 2, 2)W0 <- ICAorthW(W0)W1 <- ProDenICA(x, W0=W0,trace=TRUE,Gfunc=GPois)$W

Get the estimated value of \ (a\)W1

Calculate Amari Distance
amari(W1, target)
Comparison of two algorithms

This part attempts to reproduce fig. 14.42.

N = 1024x768Gendata <- function (Dist,N = 1024x768,p = 2){# Original Sourcess =  Scale(Cbind(Rjordan(Dist, N),Rjordan(Dist, N)))# mixing MatrixMix.mat = Mixmat(2)# Original Observationx = S%*% Mix.mat# central Xx =  Scale(X,TRUE,FALSE)# whiten xxs = SVD(x) x = sqrt(N) * Xs$u# New ObservationsMIX.MAT2 = Diag(xs$d)%*% T(xs$v)%*% Solve(Mix.mat)/ sqrtN# New Mixing matrix  return(List(x =XA =MIX.MAT2))}res = Array(NA,C(2, -, -)) for (I-inC(1: -) {for (J inC(1: -) {data = Gendata(Letters[i]) x = Data$x A = data$a W0 <- Matrix(Rnorm(2*2),2,2) W0 <- ICAORTHW(W0)# ProdenicaW1 <- Prodenica(X,w0=W0,trace=FALSE,gfunc=Gpois,restarts = 5) $W# FasticaW2 <- Prodenica(X,w0=W0,trace=FALSE,gfunc=G1,restarts = 5) $W res[1, I, j] = Amari(W1, A) res[2, I, j] = Amari(W2, A)}} Res.mean = Apply(Res,C(1,2), mean)#offset = apply (res, C (), SD)#offset = 0#res. max = Res.mean + OFFSET/4#res. Min = Res.mean-offset/4Res.max = Apply(Res,C(1,2), max) Res.min = Apply(Res,C(1,2), Min)# Plotplot(1: -, res.mean[1, ],Xlab = "Distribution",Ylab = "Amari Distance from True A",Xaxt = ' n ',type = "O",col = "Orange",pch =  +,LWD = 2,Ylim = C(0,0.5))Axis(1,at = 1: -,labels =letters[1: -])Lines(1: -, res.mean[2, ],type = "O",col = ' Blue ',pch =  +,lwd=2)legend("TopRight",C("Prodenica","Fastica"),LWD = 2,pch =  +,col = C("Orange","Blue"))#for (i in 1:18)#{# for (J in 1:2)#  {# color = C ("Orange", "Blue")# lines (c (i, I), C (Res.min[j, I], res.max[j, I]), col = Color[j], pch = 3)# Lines (C (i-0.2, i+0.2), C (Res.min[j, I], res.min[j, I]), col = Color[j], pch = 3)# Lines (C (i-0.2, i+0.2), C (Res.max[j, I], res.max[j, I]), col = Color[j], pch = 3)#  }#}

Get

Consistent with the image in the right image of Figure 14.42 FastICA ProDenICA .

Trying to plot the range of changes in the diagram, but because the book does not indicate what the range is, the standard deviation and the maximum minimum are tried, but the effect is not very good, this is an aspect that can continue to optimize. is obtained by using the standard deviation of One-fourth as its fluctuation range.

Ready to be perfected

Join Kernelica

Independent component Analysis (ICA) simulation Experiment (R language)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.