V_KMEANLBG Vector quantisation using the Linde-Buzo-Gray algorithm [X,ESQ,J]=(D,K) Inputs: D contains data vectors (one per row) K is number of centres required Outputs: X is output row vectors (K rows) ESQ is mean square error J indicates which centre each data vector belongs to Implements LBG K-means algorithm: Linde, Y., A. Buzo, and R. M. Gray, "An Algorithm for vector quantiser design," IEEE Trans Communications, vol. 28, pp.84-95, Jan 1980.

- v_kmeans V_KMEANS Vector quantisation using K-means algorithm [X,ESQ,J]=(D,K,X0,L)

0001 function [x,esq,j] = v_kmeanlbg(d,k) 0002 %V_KMEANLBG Vector quantisation using the Linde-Buzo-Gray algorithm [X,ESQ,J]=(D,K) 0003 % 0004 %Inputs: 0005 % D contains data vectors (one per row) 0006 % K is number of centres required 0007 % 0008 %Outputs: 0009 % X is output row vectors (K rows) 0010 % ESQ is mean square error 0011 % J indicates which centre each data vector belongs to 0012 % 0013 % Implements LBG K-means algorithm: 0014 % Linde, Y., A. Buzo, and R. M. Gray, 0015 % "An Algorithm for vector quantiser design," 0016 % IEEE Trans Communications, vol. 28, pp.84-95, Jan 1980. 0017 0018 0019 % Copyright (C) Mike Brookes 1998 0020 % Version: $Id: v_kmeanlbg.m 10865 2018-09-21 17:22:45Z dmb $ 0021 % 0022 % VOICEBOX is a MATLAB toolbox for speech processing. 0023 % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 0024 % 0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0026 % This program is free software; you can redistribute it and/or modify 0027 % it under the terms of the GNU General Public License as published by 0028 % the Free Software Foundation; either version 2 of the License, or 0029 % (at your option) any later version. 0030 % 0031 % This program is distributed in the hope that it will be useful, 0032 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0033 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0034 % GNU General Public License for more details. 0035 % 0036 % You can obtain a copy of the GNU General Public License from 0037 % http://www.gnu.org/copyleft/gpl.html or by writing to 0038 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 0039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0040 0041 nc=size(d,2); 0042 [x,esq,j]=v_kmeans(d,1); 0043 m=1; 0044 while m<k 0045 n=min(m,k-m); 0046 m=m+n; 0047 e=1e-4*sqrt(esq)*rand(1,nc); 0048 [x,esq,j]=v_kmeans(d,m,[x(1:n,:)+e(ones(n,1),:); x(1:n,:)-e(ones(n,1),:); x(n+1:m-n,:)]); 0049 end

Generated by