您好,欢迎来到帮我找美食网。
搜索
您的当前位置:首页层次分析法的matlab程序

层次分析法的matlab程序

来源:帮我找美食网
层次分析法的matlab程序

层次分析法的matlab程序 function [r,c]=ahpvector(x)

%AHPVECTOR Calculate the AHP ranking or weighting vector from an ... % AHP reciproal matrix. %

% R = AHPVECTOR(X) is the ordered AHP ranking based on the AHP matrix X. %

% [R,C] = AHPVECTOR(X) returns the ordered AHP ranking R % and the consistency ratio C.

% Note that C < 0.1 is considered heuristically acceptable. sztemp=size(x); n=sztemp(1); [v,d]=eig(x); i=1;

while d(i,i)myeig=d(i,i) myvec=v(:,i);

r=myvec/sum(myvec); ci=(myeig-n)/(n-1);

randomci=[1 1 0.52 0. 1.11 1.25 1.35 1.4 1.45 1.49 1.51]; if n>11 rci=1.5; else

rci=randomci(n); end c=ci/rci; if c > 0.1

s=sprintf('Warning: Consistency ratio %.3f > 0.1',c); disp([s]); end

matlab 卡方检验

function [p, Q]= chi2test(x)

% Usage: [p, Q]= chi2test(x) %

% The chi-squared test. %

% Given a number of samples this function tests the hypothesis that the samples are % independent. If Q > chi2(p, nu), the hypothesis is rejected. %

% Each column represents a variables, each row a sample. %

% If you find any errors, please let me know: . %

% ARGUMENTS:

% x Absolut numbers.

% p The prob ability value, calculated from Q. % Q The resulting Q-value. %

% EXAMPLE 1

% In region A, 324 of 556 cows were red, whereas in region B 98 of 260 were red. % [p, Q]= chi2test([324, 556-324; 98, 260-98]) % p=

% 4.2073e-08 % Q=

% 30.0515

% With an error risk of about 4e-08, we can claim that the samples are independent. %

% EXAMPLE 2

% Throw two different dices to see if they have the same probability of 1 (and 2, 3, 4, 5, 6). % We don't check if they are symetrical, only if the both behave in the same way. % [p,Q] = chi2test([15,10; 7,11; 9,7; 20,15; 26,21; 19,16]) % p=

% 0.8200 % Q =

% 2.2059

% The dices don't significantly behave differently. That is, they seem to behave in the same way. %

% HISTORY: v.1.0, first working version, 2007-08-30. %

% COPYRIGHT: (c) 2007 Peder Axensten. Use at own risk. % KEYWORDS: chi-squared test, chi-squared, chi2, test

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Check the arguments.

if(nargin ~= 1), error('One and only one argument required!'); end if(ndims(x) ~= 2), error('The argument (x) must be a 2d matrix!'); end

if(any(size(x) == 1)), error('The argument (x) must be a 2d matrix!'); end

if(any(~isreal(x))), error('All values of the argument (x) must be real values!'); end

% Calculate Q = sum( (a-np*)^2/(np*(1-p*)) ) s= size(x, 1); r= size(x, 2);

np= sum(x, 2)/sum(sum(x)) * sum(x); % p=sum(x, 2)/sum(sum(x)) and n=sum(x) Q= sum(sum((x-np).^2./(np)));

% Calculate cdf of chi-squared to Q. Degrees of freedom, v, is (r-1)*(s-1). p= 1 - gammainc(Q/2, (r-1)*(s-1)/2); end

2.6 假设检验与Matlab命令汇总

假设检验 单个总体均值(s2已知) 统计量 检验规则 接受H0 (z检验) 单个总体均值(s2未知) 单个总体方差 两个总体均值(s12,s22已知) 两个总体均值22(s1=s2未知) 两个总体方差 接受H0 0-1分布总体均值 无 H0:总体服从略 总体分布正态性 H0:总体服从略 H0:总体服从略 MATLAB命令 h=ztest(x,mu,sigma) [h,sig,ci,zval]= ztest(x,mu,sigma, alpha,tail) h=ttest(x,mu) [h,sig,ci]=ttest(x,mu,alpha,tail) 接受H0 (t检验) 无 接受H0 无 接受H0 接受H0 h=ttest2(x,y) [h,sig,ci]=ttest2 (x,y,alpha,tail) 无 接受H0 略 略 h =jbtest(x) [h,p,jbstat,cv]=jbtest(x,alpha) h=kstest(x) 略 h=lillietest(x) [h,p,lstat,cv]= lillietest(x,alpha)

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- banwoyixia.com 版权所有 湘ICP备2023022004号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务