Download code

Jump to: navigation, search

Back to OCAMAWEB

Download for Windows: zip

Download for UNIX: zip, tar.gz, tar.bz2

a_lot_of_PCAs.m

 1 % The authors of this work have released all rights to it and placed it
 2 % in the public domain under the Creative Commons CC0 1.0 waiver
 3 % (http://creativecommons.org/publicdomain/zero/1.0/).
 4 % 
 5 % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 6 % EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 7 % MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 8 % IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 9 % CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
10 % TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
11 % SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 % 
13 % Retrieved from: http://en.literateprograms.org/OCAMAWEB?oldid=19183
14 
15 function [M, v, l] = a_lot_of_PCAs(n, p, nb)
16 %< checking the argument number
17 % there can be 2 or 3 arguments
18 if nargin < 3
19   nb = 1
20 end;
21 %>
22 
23 figure; hold on;
24 %< performing ACPs
25 % the number of PCAs to be preformed is nb
26 for i=1:nb
27   %< randomized input
28   % I will perform a PCA on a gaussian n X p matrix
29   M     = randn(n,p);
30   %>
31   %< PCA
32   % I use eig but I could used SVD too
33   [v,l] = eig(M' * M);
34   l     = diag(l);
35   csl   = cumsum(l);
36   %>
37   plot(csl/csl(end));
38 end;
39 %>
40 


hijacker
hijacker
hijacker
hijacker

ocamaweb.xml

 1    <ocamaweb>
 2    <pdfgenerator file="dvipdfm" ext=".dvi"/>
 3    <keypatterns>
 4       <keypattern name="author" key="node.author" before="'" after="'"/>
 5       <keypattern name="author" key="% author" before="'" after="'"/>
 6       <keypattern name="author" key="% auteur" before="'" after="'"/>
 7       <keypattern name="title" key="% title" before="'" after="'"/>
 8       <keypattern name="title" key="% titre" before="'" after="'"/>
 9       <keypattern name="project" key="% project" before="'" after="'"/>
10       <keypattern name="project" key="% projet" before="'" after="'"/>
11       <keypattern name="mailto" key="node.mailto" before="'" after="'"/>
12       <keypattern name="mailto" key="% mailto" before="'" after="'"/>
13       <keypattern name="date" key="node.date" before="'" after="'"/>
14       <keypattern name="date" key="% date" before="'" after="'"/>
15       <keypattern name="version" key="% version" before="'" after="'"/>
16       <keypattern name="version" key="VERSION" before="=" after=";"/>
17    </keypatterns>
18    <matlabwords>
19       <keyword name="function"/>
20       <keyword name="while"/>
21       <keyword name="continue"/>
22       <keyword name="try"/>
23       <keyword name="catch"/>
24       <keyword name="for"/>
25       <keyword name="end"/>
26       <keyword name="persistent"/>
27       <keyword name="switch"/>
28       <keyword name="case"/>
29       <keyword name="if"/>
30       <keyword name="else"/>
31       <keyword name="elseif"/>
32       <keyword name="return"/>
33       <keyword name="break"/>
34       <keyword name="otherwise"/>
35    </matlabwords>
36    <info/>
37    </ocamaweb>


hijacker
hijacker
hijacker
hijacker

a_lot_of_PCAs_.m

 1 % The authors of this work have released all rights to it and placed it
 2 % in the public domain under the Creative Commons CC0 1.0 waiver
 3 % (http://creativecommons.org/publicdomain/zero/1.0/).
 4 % 
 5 % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 6 % EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 7 % MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 8 % IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 9 % CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
10 % TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
11 % SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 % 
13 % Retrieved from: http://en.literateprograms.org/OCAMAWEB?oldid=19183
14 
15 function [M, v, l] = a_lot_of_PCAs(n, p, nb)
16 %< checking the argument number
17 % there can be 2 or 3 arguments
18 if nargin < 3
19    nb = 1
20 end;
21 %>
22 figure; hold on;
23 %< performing ACPs
24 % the number of PCAs to be preformed is nb
25 for i=1:nb
26     %< randomized input
27     % I will perform a PCA on a gaussian n X p matrix
28     M     = randn(n,p);
29     %>
30     %< PCA
31     % I use eig but I could used SVD too
32     [v,l] = eig(M' * M);
33     l     = diag(l);
34     csl   = cumsum(l);
35     %>
36     plot(csl/csl(end));
37 end;
38 %>


hijacker
hijacker
hijacker
hijacker