模糊数学中模糊聚类算法的vb实现

源代码在线查看: 模糊聚类m2.bas

软件大小: 46 K
上传用户: linux_open_lab
关键词: 模糊数学 模糊聚类 算法
下载地址: 免注册下载 普通下载 VIP

相关代码

				Attribute VB_Name = "modDataTreat"
				'模糊聚类分析
				'数据预处理方法模块
				Option Explicit
				'数据的标准差变换
				'X(1 To N,1 To M):原始数据,执行后保存变换后的数据
				Public Sub Data_T1(X() As Double)
				    Dim M As Integer, N As Integer, I As Integer, J As Integer
				    Dim Ave As Double, S As Double
				    N = UBound(X, 1): M = UBound(X, 2)          'N:样品数;M:变量数
				    For J = 1 To M
				        Ave = 0
				        For I = 1 To N
				            Ave = Ave + X(I, J)
				        Next I
				        Ave = Ave / N                           'Ave是平均值
				        S = 0
				        For I = 1 To N
				            S = S + (X(I, J) - Ave) ^ 2
				        Next I
				        S = Sqr(S / N)                          'S是标准差
				        For I = 1 To N
				            X(I, J) = (X(I, J) - Ave) / S       '标准差标准化变换
				        Next I
				    Next J
				End Sub
				
				'数据的极差变换
				'X(1 To N,1 To M):原始数据,执行后保存变换后的数据
				Public Sub Data_T2(X() As Double)
				    Dim M As Integer, N As Integer, I As Integer, J As Integer
				    Dim xMax As Double, xMin As Double, d As Double
				    N = UBound(X, 1): M = UBound(X, 2)          'N:样品数;M:变量数
				    For J = 1 To M
				        xMax = -100000000: xMin = 100000000
				        For I = 1 To N
				            If X(I, J) > xMax Then xMax = X(I, J)
				            If X(I, J) < xMin Then xMin = X(I, J)
				        Next I
				        d = xMax - xMin                         'd是极差
				        For I = 1 To N
				            X(I, J) = (X(I, J) - xMin) / d      '极差标准化变换
				        Next I
				    Next J
				End Sub
				
							

相关资源