comparison general/numerical/pdev.m @ 4:e44f49929e56

Adding reorganised general toolbox, now in several subdirectories.
author samer
date Sat, 12 Jan 2013 19:21:22 +0000
parents
children 8476b3d9d295
comparison
equal deleted inserted replaced
3:3f77126f7b5f 4:e44f49929e56
1 function N=pdev(p,A,D)
2 % pdev - p-deviation, generalisation of stddev for exponents other than 2
3 %
4 % pdev :: nonneg, [[D1]], I:natural -> [[D2]].
5 % pdev :: nonneg, [[N D]] -> [[ 1 D]].
6 %
7 % where D2 = set(D1,I,1), ie the Ith dimension is
8 % collapsed. I defaults to 1. The p-deviation is defined as
9 % pdev(p,x,i) = mean(abs(x).^p,i).^(1/p)
10 %
11 % See also pnorm.
12
13 if nargin<2, D=1; end;
14
15 % Should these be sum or mean?
16 if p==2
17 N=sqrt(mean(abs(A).^2,D));
18 else
19 N=mean(abs(A).^p,D).^(1/p);
20 end
21
22