wolffd@0
|
1 function varargout = mirkurtosis(orig,varargin)
|
wolffd@0
|
2 % k = mirkurtosis(x) calculates the kurtosis of x, indicating whether
|
wolffd@0
|
3 % the curve is peaked or flat relative to a normal distribution.
|
wolffd@0
|
4 % x can be either:
|
wolffd@0
|
5 % - a spectrum (spectral kurtosis),
|
wolffd@0
|
6 % - an envelope (temporal kurtosis), or
|
wolffd@0
|
7 % - any histogram.
|
wolffd@0
|
8
|
wolffd@0
|
9
|
wolffd@0
|
10 varargout = mirfunction(@mirkurtosis,orig,varargin,nargout,struct,@init,@main);
|
wolffd@0
|
11
|
wolffd@0
|
12
|
wolffd@0
|
13 function [x type] = init(x,option)
|
wolffd@0
|
14 if not(isamir(x,'mirdata')) || isamir(x,'miraudio')
|
wolffd@0
|
15 x = mirspectrum(x);
|
wolffd@0
|
16 end
|
wolffd@0
|
17 type = 'mirscalar';
|
wolffd@0
|
18
|
wolffd@0
|
19
|
wolffd@0
|
20 function k = main(x,option,postoption)
|
wolffd@0
|
21 if iscell(x)
|
wolffd@0
|
22 x = x{1};
|
wolffd@0
|
23 end
|
wolffd@0
|
24 y = peaksegments(@kurtosis,get(x,'Data'),...
|
wolffd@0
|
25 get(x,'Pos'),...
|
wolffd@0
|
26 get(mircentroid(x),'Data'),...
|
wolffd@0
|
27 get(mirspread(x),'Data'));
|
wolffd@0
|
28 if isa(x,'mirspectrum')
|
wolffd@0
|
29 t = 'Spectral kurtosis';
|
wolffd@0
|
30 elseif isa(x,'mirenvelope')
|
wolffd@0
|
31 t = 'Temporal kurtosis';
|
wolffd@0
|
32 else
|
wolffd@0
|
33 t = ['Kurtosis of ',get(x,'Title')];
|
wolffd@0
|
34 end
|
wolffd@0
|
35 k = mirscalar(x,'Data',y,'Title',t,'Unit','');
|
wolffd@0
|
36
|
wolffd@0
|
37
|
wolffd@0
|
38 function k = kurtosis(d,p,c,s)
|
wolffd@0
|
39 k = sum((p-c).^4.*d) ./ sum(d) ./ s.^4; |