?? lloydmax.m
字號:
function [a,y,dist]=lloydmax(funfcn,b,n,tol,p1,p2,p3)%LLOYDMAX Returns the the Lloyd-Max quantizer and the mean-squared % quantization error for a symmetric distribution.% [A,Y,DIST]=LLOYDMAX(FUNFCN,B,N,TOL,P1,P2,P3) % funfcn=The density function given % in an m-file. It can depent on up to three % parameters, p1,p2,p3.% a=The vector giving the boundaries of the % quantization regions. % [-b,b] approximates support of the density function.% n=The number of quantization regions.% y=The quantization levels.% p1,p2,p3=Parameters of funfcn.% tol=the relative error.args=[];for j=1:nargin-4 args=[args,',p',int2str(j)];endargs=[args,')'];v=eval(['variance(funfcn,-b,b,tol',args]);a(1)=-b;d=2*b/n;for i=2:n a(i)=a(i-1)+d;enda(n+1)=b;dist=v;[y,newdist]=eval(['mse_dist(funfcn,a,tol',args]);while(newdist<0.99*dist), for i=2:n a(i)=(y(i-1)+y(i))/2; end dist=newdist; [y,newdist]=eval(['mse_dist(funfcn,a,tol',args]);end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -