comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirskewness.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function varargout = mirskewness(orig,varargin)
2 % s = skewness(x) calculates the skewness of x, showing the (lack of)
3 % symmetry of the curve.
4 % x can be either:
5 % - a spectrum (spectral skewness),
6 % - an envelope (temporal skewness), or
7 % - any histogram.
8
9
10 varargout = mirfunction(@mirskewness,orig,varargin,nargout,struct,@init,@main);
11
12
13 function [x type] = init(x,option)
14 if not(isamir(x,'mirdata')) || isamir(x,'miraudio')
15 x = mirspectrum(x);
16 end
17 type = 'mirscalar';
18
19
20 function s = main(x,option,postoption)
21 if iscell(x)
22 x = x{1};
23 end
24 y = peaksegments(@skewness,get(x,'Data'),...
25 get(x,'Pos'),...
26 get(mircentroid(x),'Data'),...
27 get(mirspread(x),'Data'));
28 if isa(x,'mirspectrum')
29 t = 'Spectral skewness';
30 elseif isa(x,'mirenvelope')
31 t = 'Temporal skewness';
32 else
33 t = ['Skewness of ',get(x,'Title')];
34 end
35 s = mirscalar(x,'Data',y,'Title',t,'Unit','');
36
37
38 function s = skewness(d,p,c,sp)
39 s = sum((p-c).^3.*d) ./ sum(d) ./ sp.^3;