TRITEST.M
资源名称:speech.rar [点击查看]
上传用户:ay_070428
上传日期:2014-12-04
资源大小:11427k
文件大小:2k
源码类别:
语音合成与识别
开发平台:
Matlab
- % ====== Exhaustive test of triangle inequality
- index = combinat(1:waveFileNum, 3);
- caseNum = size(index,1);
- fprintf('Exhaustive testing %g cases of triangle inequality ===> ', 3*caseNum);
- tic
- deviation = zeros(caseNum, 3);
- allDistance = zeros(caseNum, 3);
- h = waitbar(0, ['Testing ', int2str(caseNum), ' cases of triangular inequality...']);
- for i = 1:caseNum,
- if mod(i, 1000)==0,
- waitbar(i/caseNum, h);
- end
- a = index(i, 1);
- b = index(i, 2);
- c = index(i, 3);
- dist1 = distance(a,b);
- dist2 = distance(b,c);
- dist3 = distance(a,c);
- allDistance(i, :) = [dist1, dist2, dist3];
- d1 = dist1+dist2-dist3;
- d2 = dist2+dist3-dist1;
- d3 = dist1+dist3-dist2;
- deviation(i, :) = [d1, d2, d3];
- end
- fprintf('%4.2f secondsn', toc);
- % ====== Get rid of the cases when 1000000 is involved
- ind = find(any(allDistance>=1000000, 2));
- fprintf('Deleting %g cases that involves 1000000n', 3*length(ind));
- deviation(ind, :) = [];
- % ====== Display the results
- bad = sum(sum(deviation<0));
- total = prod(size(deviation));
- fprintf('Percentage of cases that violates the triangle inequality = %g/%g = %g%%n', bad, total, bad/total*100);
- hist(deviation, 100);
- title('Histogram of deviation');
- % ====== Save the results
- %save tritest distance deviation
- devIndex = deviation<0;
- distDiff = abs([allDistance(:,1)-allDistance(:,2), allDistance(:,2)-allDistance(:,3), allDistance(:,3)-allDistance(:,1)]);
- % Normal index
- index2 = find(sum(devIndex,2)<1);
- D2 = distDiff(index2, :);
- figure;
- [N1, X1] = hist(max(D2'), 100);
- bar(X1,N1);
- % Problematic index
- index1 = find(sum(devIndex,2)>=1);
- if ~isempty(index1),
- D1 = distDiff(index1, :);
- [N2, X2] = hist(max(D1'), 100);
- hold on
- h = bar(X2,N2, 0.5);
- set(h, 'facecolor', 'y');
- hold off
- title('Hist. of max. dist. differences of any three wave files');
- end
- legend('Fullfil tri. inequality', 'Not fullfil tri. inequality');
- title('Histograms of max. diff. of triangle''s three sides');