"Fossies" - the Fresh Open Source Software Archive

Member "sip-0.12.1/macros/sip_pca_test.sce" (18 Jun 2015, 1551 Bytes) of package /linux/privat/sip-0.12.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Scilab source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 data = [
    2      0     1
    3      0     1];
    4 // manifold is line from (0,0) to (1,1)
    5 
    6 [data_db, mean_db]= sip_pca(data,1)
    7 
    8 x_test = [0; 0];
    9 [x_proj_pca, x_proj_orig] = sip_pca_project(x_test, data_db, mean_db)
   10 disp 'result of projection in original space should be [0,0]'
   11 
   12 x_test = [1; 1];
   13 [x_proj_pca, x_proj_orig] = sip_pca_project(x_test, data_db, mean_db)
   14 disp 'result of projection in original space should be [1,1]'
   15 
   16 x_test = [0.5; 0.5];
   17 [x_proj_pca, x_proj_orig] = sip_pca_project(x_test, data_db, mean_db)
   18 disp 'result of projection in original space should be [0.5,0.5]'
   19 
   20 x_test = [0.4; 0.6];
   21 [x_proj_pca, x_proj_orig] = sip_pca_project(x_test, data_db, mean_db)
   22 disp 'result of projection in original space should be [0.5,0.5]'
   23 
   24 // ---------------------------
   25 // increasing the dimension to 2 should make the projection operator the
   26 // identity, as the manifold is now the entire plane.
   27 
   28 [data_db, mean_db]= sip_pca(data,2)
   29 
   30 x_test = [0; 0];
   31 [x_proj_pca, x_proj_orig] = sip_pca_project(x_test, data_db, mean_db)
   32 disp 'result of projection in original space should be [0,0]'
   33 
   34 x_test = [1; 1];
   35 [x_proj_pca, x_proj_orig] = sip_pca_project(x_test, data_db, mean_db)
   36 disp 'result of projection in original space should be [1,1]'
   37 
   38 x_test = [0.5; 0.5];
   39 [x_proj_pca, x_proj_orig] = sip_pca_project(x_test, data_db, mean_db)
   40 disp 'result of projection in original space should be [0.5,0.5]'
   41 
   42 x_test = [0.4; 0.6];
   43 [x_proj_pca, x_proj_orig] = sip_pca_project(x_test, data_db, mean_db)
   44 disp 'result of projection in original space should be *** [0.4,0.6] ***'