File: st_deviation.sci

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (19 lines) | stat: -rw-r--r-- 542 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function sd=st_deviation(x,cr)
//Copyright Inria/Enpc 
//Philippe.Castagliola Ecole des Mines de Nantes
// 
[argout,argin]=argn(0);
if (argin<1)|(argin>2)
  error('incorrect number of arguments');
end
if x == [] then sd=%nan;return ;end 
[m n]=size(x);
if argin==1
  sd=sqrt(sum((x-mean(x)).^2)/(m*n-1));
elseif cr=='c'|cr==2
  sd=sqrt(sum((x-mean(x,'c')*ones(x(1,:))).^2,'c')/(n-1));
elseif cr=='r'|cr==1
  sd=sqrt(sum((x-ones(x(:,1))*mean(x,'r')).^2,'r')/(m-1));
else
  error('2nd argument cr must be equal to ''c'' or 2, ''r''or  1');
end