fastica.docx
- 文档编号:27999889
- 上传时间:2023-07-07
- 格式:DOCX
- 页数:20
- 大小:19.67KB
fastica.docx
《fastica.docx》由会员分享,可在线阅读,更多相关《fastica.docx(20页珍藏版)》请在冰豆网上搜索。
fastica
function[Out1,Out2,Out3]=fastica(mixedsig,varargin)
%FASTICA-FastIndependentComponentAnalysis
%
%FastICAforMatlab7.xand6.x
%Version2.5,October192005
%Copyright(c)HugoGävert,JarmoHurri,JaakkoSärelä,andAapoHyvärinen.
%
%FASTICA(mixedsig)estimatestheindependentcomponentsfromgiven
%multidimensionalsignals.Eachrowofmatrixmixedsigisone
%observedsignal.FASTICAusesHyvarinen'sfixed-pointalgorithm,
%seehttp:
//www.cis.hut.fi/projects/ica/fastica/.Outputfromthe
%functiondependsonthenumberoutputarguments:
%
%[icasig]=FASTICA(mixedsig);therowsoficasigcontainthe
%estimatedindependentcomponents.
%
%[icasig,A,W]=FASTICA(mixedsig);outputstheestimatedseparating
%matrixWandthecorrespondingmixingmatrixA.
%
%[A,W]=FASTICA(mixedsig);givesonlytheestimatedmixingmatrix
%AandtheseparatingmatrixW.
%
%Someoptionalargumentsinduceotheroutputformats,seebelow.
%
%AgraphicaluserinterfaceforFASTICAcanbelaunchedbythe
%commandFASTICAG
%
%FASTICAcanbecalledwithnumerousoptionalarguments.Optional
%argumentsaregiveninparameterpairs,sothatfirstargumentis
%thenameoftheparameterandthenextargumentisthevaluefor
%thatparameter.Optionalparameterpairscanbegiveninanyorder.
%
%OPTIONALPARAMETERS:
%
%ParameternameValuesanddescription
%
%======================================================================
%--Basicparametersinfixed-pointalgorithm:
%
%'approach'(string)Thedecorrelationapproachused.Canbe
%symmetric('symm'),i.e.estimateallthe
%independentcomponentinparallel,or
%deflation('defl'),i.e.estimateindependent
%componentone-by-onelikeinprojectionpursuit.
%Defaultis'defl'.
%
%'numOfIC'(integer)Numberofindependentcomponentsto
%beestimated.Defaultequalsthedimensionofdata.
%
%======================================================================
%--Choosingthenonlinearity:
%
%'g'(string)Choosesthenonlinearitygusedin
%thefixed-pointalgorithm.Possiblevalues:
%
%Valueof'g':
Nonlinearityused:
%'pow3'(default)g(u)=u^3
%'tanh'g(u)=tanh(a1*u)
%'gaussg(u)=u*exp(-a2*u^2/2)
%'skew'g(u)=u^2
%
%'finetune'(string)Choosesthenonlinearitygusedwhen
%fine-tuning.Inadditiontosamevalues
%asfor'g',thepossiblevalue'finetune'is:
%'off'fine-tuningisdisabled.
%
%'a1'(number)Parametera1usedwheng='tanh'.
%Defaultis1.
%'a2'(number)Parametera2usedwheng='gaus'.
%Defaultis1.
%
%'mu'(number)Stepsize.Defaultis1.
%Ifthevalueofmuisotherthan1,thenthe
%programwillusethestabilizedversionofthe
%algorithm(seealsoparameter'stabilization').
%
%
%'stabilization'(string)Values'on'or'off'.Default'off'.
%Thisparametercontrolswethertheprogramuses
%thestabilizedversionofthealgorithmor
%not.Ifthestabilizationison,thenthevalue
%ofmucanmomentarilybehalvediftheprogram
%sensesthatthealgorithmisstuckbetweentwo
%points(thisiscalledastroke).Alsoifthere
%isnoconvergencebeforehalfofthemaximum
%numberofiterationshasbeenreachedthenmu
%willbehalvedfortherestoftherounds.
%
%======================================================================
%--Controllingconvergence:
%
%'epsilon'(number)Stoppingcriterion.Defaultis0.0001.
%
%'maxNumIterations'(integer)Maximumnumberofiterations.
%Defaultis1000.
%
%'maxFinetune'(integer)Maximumnumberofiterationsin
%fine-tuning.Default100.
%
%'sampleSize'(number)[0-1]Percentageofsamplesusedin
%oneiteration.Samplesarechoseninrandom.
%Defaultis1(allsamples).
%
%'initGuess'(matrix)InitialguessforA.Defaultisrandom.
%Youcannowdoa"onemore"likethis:
%[ica,A,W]=fastica(mix,'numOfIC',3);
%[ica2,A2,W2]=fastica(mix,'initGuess',A,'numOfIC',4);
%
%======================================================================
%--Graphicsandtextoutput:
%
%'verbose'(string)Either'on'or'off'.Defaultis
%'on':
reportprogressofalgorithmintextformat.
%
%'displayMode'(string)Plotrunningestimatesofindependent
%components:
'signals','basis','filters'or
%'off'.Defaultis'off'.
%
%'displayInterval'Numberofiterationsbetweenplots.
%Defaultis1(plotaftereveryiteration).
%
%======================================================================
%--Controllingreductionofdimensionandwhitening:
%
%Reductionofdimensioniscontrolledby'firstEig'and'lastEig',or
%alternativelyby'interactivePCA'.
%
%'firstEig'(integer)Thisand'lastEig'specifytherangefor
%eigenvaluesthatareretained,'firstEig'is
%theindexoflargesteigenvaluetobe
%retained.Defaultis1.
%
%'lastEig'(integer)Thisistheindexofthelast(smallest)
%eigenvaluetoberetained.Defaultequalsthe
%dimensionofdata.
%
%'interactivePCA'(string)Either'on'or'off'.Whenset'on',the
%eigenvaluesareshowntotheuserandthe
%rangecanbespecifiedinteractively.Default
%is'off'.Canalsobesetto'gui'.Thentheuser
%canusethesameGUIthat'sinFASTICAG.
%
%Ifyoualreadyknowtheeigenvaluedecompositionofthecovariance
%matrix,youcanavoidcomputingitagainbygivingitwiththe
%followingoptions:
%
%'pcaE'(matrix)Eigenvectors
%'pcaD'(matrix)Eigenvalues
%
%Ifyoualreadyknowthewhiteneddata,youcangiveitdirectlyto
%thealgorithmusingthefollowingoptions:
%
%'whiteSig'(matrix)Whitenedsignal
%'whiteMat'(matrix)Whiteningmatrix
%'dewhiteMat'(matrix)dewhiteningmatrix
%
%Ifvaluesforallthe'whiteSig','whiteSig'and'dewhiteMat'are
%supplied,theywillbeusedincomputingtheICA.PCAandwhitening
%arenotperformed.Though'mixedsig'isnotusedinthemain
%algorithmitstillmustbeentered-somevaluesarestill
%calculatedfromit.
%
%Performingpreprocessingonlyispossiblebytheoption:
%
%'only'(string)ComputeonlyPCAi.e.reductionof
%dimension('pca')oronlyPCApluswhitening
%('white').Defaultis'all':
doICAestimation
%aswell.Thisoptionchangestheoutput
%formataccordingly.Forexample:
%
%[whitesig,WM,DWM]=FASTICA(mixedsig,
%'only','white')
%returnsthewhitenedsignals,thewhiteningmatrix
%(WM)andthedewhiteningmatrix(DWM).(Seealso
%WHITENV.)InFastICAthewhiteningmatrixperforms
%whiteningandthereductionofdimension.Dewhitening
%matrixisthepseudoinverseofwhiteningmatrix.
%
%[E,D]=FASTICA(mixedsig,'only','pca')
%returnstheeigenvector(E)anddiagonal
%eigenvalue(D)matricescontainingthe
%selectedsubspaces.
%
%======================================================================
%EXAMPLES
%
%[icasig]=FASTICA(mixedsig,'approach','symm','g','tanh');
%DoICAwithtanhnonlinearityandinparallel(like
%maximumlikelihoodestimationforsupergaussiandata).
%
%[icasig]=FASTICA(mixedsig,'lastEig',10,'numOfIC',3);
%Reducedimensionto10,andestimateonly3
%independentcomponents.
%
%[icasig]=FASTICA(mixedsig,'verbose','off','displayMode','off');
%Don'toutputconvergencereportsanddon'tplot
%independentcomponents.
%
%
%AgraphicaluserinterfaceforFASTICAcanbelaunchedbythe
%commandFASTICAG
%
%SeealsoFASTICAG
%@(#)$Id:
fastica.m,v1.142005/10/1913:
05:
34jarmoExp$
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Checksomebasicrequirementsofthedata
ifnargin==0,
error('Youmustsupplythemixeddataasinputargument.');
end
iflength(size(mixedsig))>2,
error('Inputdatacannothavemorethantwodimensions.');
end
ifany(any(isnan(mixedsig))),
error('InputdatacontainsNaN''s.');
end
if~isa(mixedsig,'double')
fprintf('Warning:
convertinginputdataintoregular(double)precision.\n');
mixedsig=double(mixedsig);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Removethemeanandcheckthedata
[mixedsig,mixedmean]=remmean(mixedsig);
[Dim,NumOfSampl]=size(mixedsig);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Defaultvaluesforoptionalparameters
%All
verbose='on';
%Defaultvaluesfor'pcamat'parameters
firstEig=1;
lastEig=Dim;
interactivePCA='off';
%Defaultvaluesfor'fpica'parameters
approach='defl';
numOfIC=Dim;
g='pow3';
finetune='off';
a1=1;
a2=1;
myy=1;
stabilization='off';
epsilon=0.0001;
maxNumIterations=1000;
maxFinetune=5;
initState='rand';
guess=0;
sampleSize=1;
displayMode='off';
displayInterval=1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%ParametersforfastICA-i.e.thisfile
b_verbose=1;
jumpPCA=0;
jumpWhitening=0;
only=3;
userNumOfIC=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Readtheoptionalparameters
if(rem(length(varargin),2)==1)
error('Optionalparametersshouldalwaysgobypairs');
else
fori=1:
2:
(length(varargin)-1)
if~ischar(varargin{i}),
error(['Unknowntypeofoptionalparametername(parameter'...
'namesmustbestrings).']);
end
%changethevalueofparameter
switchlower(varargin{i})
case'stabilization'
stabilization=lower(varargin{i+1});
case'maxfinetune'
maxFinetune=varargin{i+1};
case'samplesize'
sampleSize=varargin{i+1};
case'verbose'
verbose=lower(varargin{i+1});
%silencethisprogramalso
ifstrcmp(verbose,'off'),b_verbose=0;end
case'firsteig'
firstEig=varargin{i+1};
case'lasteig'
lastEig=varargi
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- fastica