kolnorm.m

来自「人工神经网络:MATLAB源程序用于训练测试」· M 代码 · 共 57 行

M
57
字号
%#											
%# function [percrep] = kolnorm(xrep,ns,nr,alpha);					
%#									    
%# AIM:		Performs a Kolmogorov-Smirnov test for normality on replicate	
%#		objects at different levels, and returns the percentage of 
%#		objects not normally distributed at each level.		 
%#									    
%# PRINCIPLE:	The test consists in determining the largest difference between
%#		two cumulative relative frequency distributions: the observed
%#		distribution and the expected (normal) distribution. The test 
%#		is only applicable to continuous distributions.		
%#									
%# REFERENCE:   "Handbook of Chemometrics and Qualimetrics, Part A"	
%#		Massart, Vandeginste, Buydens, De Jong, Lewi, Smeyers-Verbeke
%#		Elsevier, 1997, p.117.				
%#									     
%# INPUT:	xrep(ns*nr,nl):	Matrix with nr replicate sets of ns objects at
%# 				nl levels.				
%#		ns(1,1):	Number of objects in the set.		
%# 		nr(1,1):	Number of replicates sets. 		
%#  		alpha(1,1):	Critical level to apply the test (0.1, 0.05 or
%#				0.01).Ex: alpha=0.05 --> Test at the 5% level.
%#									    	 
%# OUTPUT:	percrep(1,nl): 	Percentage of replicate objects not normally 
%#				distributed at each level.	
%#									     
%# SUBROUTINES:	kolmog.m:	Kolmogorov-Smirnov test		
%#									    
%# AUTHOR:	Frederic Despagne					 
%#		Copyright (c) 1998 for ChemoAC				 
%#		Dienst FABI, Vrije Universiteit Brussels	
%#		Laarbeeklaan 103 Jette					    
%#									    
%# VERSION: 1.1 (28/12/1998)						   
%#									    
%# TEST:								    
%#									    

function [percrep] = kolnorm(xrep,ns,nr,alpha);

[m,n] = size(xrep);

for i = 1:n
	xreplic = reshape(xrep(:,i),ns,nr);
	res = 0;
	for j = 1:ns
		[ks,kscrit] = kolmog(xreplic(j,:),alpha);
		if ks > kscrit
			res = res+1;
		end
		percrep(i) = res/ns;
	end
end

percrep = 100*percrep;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?