comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirkurtosis.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 = mirkurtosis(orig,varargin)
2 % k = mirkurtosis(x) calculates the kurtosis of x, indicating whether
3 % the curve is peaked or flat relative to a normal distribution.
4 % x can be either:
5 % - a spectrum (spectral kurtosis),
6 % - an envelope (temporal kurtosis), or
7 % - any histogram.
8
9
10 varargout = mirfunction(@mirkurtosis,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 k = main(x,option,postoption)
21 if iscell(x)
22 x = x{1};
23 end
24 y = peaksegments(@kurtosis,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 kurtosis';
30 elseif isa(x,'mirenvelope')
31 t = 'Temporal kurtosis';
32 else
33 t = ['Kurtosis of ',get(x,'Title')];
34 end
35 k = mirscalar(x,'Data',y,'Title',t,'Unit','');
36
37
38 function k = kurtosis(d,p,c,s)
39 k = sum((p-c).^4.*d) ./ sum(d) ./ s.^4;