annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirkurtosis.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function varargout = mirkurtosis(orig,varargin)
Daniel@0 2 % k = mirkurtosis(x) calculates the kurtosis of x, indicating whether
Daniel@0 3 % the curve is peaked or flat relative to a normal distribution.
Daniel@0 4 % x can be either:
Daniel@0 5 % - a spectrum (spectral kurtosis),
Daniel@0 6 % - an envelope (temporal kurtosis), or
Daniel@0 7 % - any histogram.
Daniel@0 8
Daniel@0 9
Daniel@0 10 varargout = mirfunction(@mirkurtosis,orig,varargin,nargout,struct,@init,@main);
Daniel@0 11
Daniel@0 12
Daniel@0 13 function [x type] = init(x,option)
Daniel@0 14 if not(isamir(x,'mirdata')) || isamir(x,'miraudio')
Daniel@0 15 x = mirspectrum(x);
Daniel@0 16 end
Daniel@0 17 type = 'mirscalar';
Daniel@0 18
Daniel@0 19
Daniel@0 20 function k = main(x,option,postoption)
Daniel@0 21 if iscell(x)
Daniel@0 22 x = x{1};
Daniel@0 23 end
Daniel@0 24 y = peaksegments(@kurtosis,get(x,'Data'),...
Daniel@0 25 get(x,'Pos'),...
Daniel@0 26 get(mircentroid(x),'Data'),...
Daniel@0 27 get(mirspread(x),'Data'));
Daniel@0 28 if isa(x,'mirspectrum')
Daniel@0 29 t = 'Spectral kurtosis';
Daniel@0 30 elseif isa(x,'mirenvelope')
Daniel@0 31 t = 'Temporal kurtosis';
Daniel@0 32 else
Daniel@0 33 t = ['Kurtosis of ',get(x,'Title')];
Daniel@0 34 end
Daniel@0 35 k = mirscalar(x,'Data',y,'Title',t,'Unit','');
Daniel@0 36
Daniel@0 37
Daniel@0 38 function k = kurtosis(d,p,c,s)
Daniel@0 39 k = sum((p-c).^4.*d) ./ sum(d) ./ s.^4;