]> Creatis software - CreaPhase.git/blob - octave_packages/nnet-0.1.13/poststd.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nnet-0.1.13 / poststd.m
1 ## Copyright (C) 2006 Michel D. Schmid  <michaelschmid@users.sourceforge.net>
2 ##
3 ##
4 ## This program is free software; you can redistribute it and/or modify it
5 ## under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
8 ##
9 ## This program is distributed in the hope that it will be useful, but
10 ## WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 ## General Public License for more details.
13 ##
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program; see the file COPYING.  If not, see
16 ## <http://www.gnu.org/licenses/>.
17
18 ## -*- texinfo -*-
19 ## @deftypefn {Function File} {}[@var{Pp},@var{Tt}] = poststd(@var{Pn},@var{meanp},,@var{stdP},@var{Tn},@var{meanT},@var{stdT})
20 ## @code{poststd} postprocesses the data which has been preprocessed by @code{prestd}.
21 ## @end deftypefn
22
23 ## @seealso{prestd,trastd}
24
25 ## Author: Michel D. Schmid
26
27 function [Pp,Tt] = poststd(Pn,meanp,stdp,Tn,meant,stdt)
28
29   ## check range of input arguments
30   error(nargchk(3,6,nargin))
31   if (nargin==4)
32     error("4 input arguments are not allowed!");
33   endif
34   if (nargin==5)
35     error("5 input arguments are not allowed!");
36   endif
37
38   ## do first inputs
39   ## set all standard deviations which are zero to 1
40   [nRowsII, nColumnsII] = size(Pn);
41   rowZeros = zeros(nRowsII,1);
42   findZeros = find(stdp==0);
43   rowZeros(findZeros)=1;
44   nequal = !rowZeros;
45   if (sum(rowZeros) != 0)
46     warning("Some standard deviations are zero. Those inputs won't be transformed.");
47     meanpZero = meanp.*nequal;
48     stdpZero = stdp.*nequal + 1*rowZeros;
49   else
50     meanpZero = meanp;
51     stdpZero = stdp;
52   endif
53   
54   ## calculate the postprocessed inputs
55   nColumnsIIone = ones(1,nColumnsII);
56   Pp = (stdpZero*nColumnsIIone).*Pn + meanpZero*nColumnsIIone;
57
58   ## do also targets
59   if ( nargin==6 )
60     # now set all standard deviations which are zero to 1
61     [nRowsIII, nColumnsIII] = size(stdt);
62     rowZeros = zeros(nRowsIII,1);
63     findZeros = find(stdt==0);
64     rowZeros(findZeros)=1;
65     nequal = !rowZeros;
66     if (sum(rowZeros) != 0)
67       warning("Some standard deviations are zero. Those targets won't be transformed.");
68       meantZero = meant.*nequal;
69       stdtZero = stdt.*nequal + 1*rowZeros;
70     else
71       meantZero = meant;
72       stdtZero = stdt;
73     endif
74
75     ## calculate the postprocessed targets
76     nColumnsIIIone = ones(1,nColumnsIII);
77     Tt = (stdtZero*nColumnsIIIone).*Tn + meantZero*nColumnsIIIone;
78   endif
79
80 endfunction