期望Ex:最能代表定性概念的点。
熵En:相当于概率论的方差,隶属度的模糊程度。
超熵He:熵的熵,反映偏离正态分布的程度,隶属度的不确定性。
定量——〉定性
需要确定度信息的逆向云模型
python代码:
def computeCloud1(x,y):#一维逆向云(方法一,需确定度)
i=0
while(i0.999):
del x[i]
del y[i]
i=i+1
x=np.array(x)
y=np.array(y)
Ex=np.mean(x)
En=np.zeros(x.shape)
for i in range(len(x)):
En[i]=np.abs(x[i]-Ex)/pow(-2*math.log(y[i],math.e),1/2)
En_1=np.mean(En)
He=np.sqrt(np.std(En))
return Ex,En_1,He
无需确定度信息的逆向云模型
python代码:
def computeCloud2(x):#一维逆向云发生器(方法二,无需确定度)
x=np.array(x);
Ex=np.mean(x);
En=np.sqrt(np.pi/2)*np.mean(np.abs(x-Ex))
S2=np.std(x)
He=np.sqrt(np.abs(S2*S2-En*En))
return Ex,En,He
python代码:
def forwardCloud(Ex,En,He,N): #正向云模型(生成云)
cloudpoint=[];
for i in range(N):
En_1=np.random.normal(En,He)
x=np.random.normal(Ex,abs(En_1))
y=math.exp(-pow(x-Ex,2)/(2*pow(En_1,2)))
cloudpoint.append([x,y])
return cloudpoint
和一维原理差不多
u = e − ( ( x − E x ) 2 2 ( E n x ′ ) 2 + ( y − E y ) 2 2 ( E n y ′ ) 2 ) u=e^{-(\frac{(x-Ex)^2}{2(Enx')^2}+\frac{(y-Ey)^2}{2(Eny')^2})} u=e−(2(Enx′)2(x−Ex)2+2(Eny′)2(y−Ey)2)
python代码:
def twoDimensionforwardCloud(Ex1,En1,He1,Ex2,En2,He2,N):#二维正向云模型(生成云)
cloudpoint=[];
for i in range(N):
t1=np.random.normal()
t2=np.random.normal()
En1_1=He1*t1+En1
En2_1=He2*t2+En2
t1=np.random.normal()
t2=np.random.normal()
x=En1_1*t1+Ex1
y=En2_1*t2+Ex2
z=math.exp(-1/2*(pow(x-Ex1,2)/(pow(En1_1,2))+pow(y-Ex2,2)/(pow(En2_1,2))))
cloudpoint.append([x,y,z])
return cloudpoint
u = e − ( ( x − E x ) 2 2 ( E n x ′ ) 2 + ( y − E y ) 2 2 ( E n y ′ ) 2 ) = u x + u y u=e^{-(\frac{(x-Ex)^2}{2(Enx')^2}+\frac{(y-Ey)^2}{2(Eny')^2})}=u_x+u_y u=e−(2(Enx′)2(x−Ex)2+2(Eny′)2(y−Ey)2)=ux+uy
python代码:
def mutiForwardCloud(Ex,En,He,N):#多维云生成
cloudpoint=np.zeros([N,len(Ex)+1]);
muti_u=np.zeros([N,len(Ex)]);
i=0;
for ex,en,he in zip(Ex,En,He):
sub_cloudpoint=forwardCloud(ex,en,he,N)
x=[x[0] for x in sub_cloudpoint]
cloudpoint[:,i]=x
u=[x[1] for x in sub_cloudpoint]
muti_u[:,i]=u
i=i+1
cloudpoint[:,i]=muti_u.prod(1)
return cloudpoint
# -*- coding: utf-8 -*-
import math
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D #画三维图
def forwardCloud(Ex,En,He,N): #正向云模型(生成云)
cloudpoint=[];
for i in range(N):
En_1=np.random.normal(En,He)
x=np.random.normal(Ex,abs(En_1))
y=math.exp(-pow(x-Ex,2)/(2*pow(En_1,2)))
cloudpoint.append([x,y])
return cloudpoint
def twoDimensionforwardCloud(Ex1,En1,He1,Ex2,En2,He2,N):#二维正向云模型(生成云)
cloudpoint=[];
for i in range(N):
t1=np.random.normal()
t2=np.random.normal()
En1_1=He1*t1+En1
En2_1=He2*t2+En2
t1=np.random.normal()
t2=np.random.normal()
x=En1_1*t1+Ex1
y=En2_1*t2+Ex2
z=math.exp(-1/2*(pow(x-Ex1,2)/(pow(En1_1,2))+pow(y-Ex2,2)/(pow(En2_1,2))))
cloudpoint.append([x,y,z])
return cloudpoint
def mutiForwardCloud(Ex,En,He,N):#多维云生成
cloudpoint=np.zeros([N,len(Ex)+1]);
muti_u=np.zeros([N,len(Ex)]);
i=0;
for ex,en,he in zip(Ex,En,He):
sub_cloudpoint=forwardCloud(ex,en,he,N)
x=[x[0] for x in sub_cloudpoint]
cloudpoint[:,i]=x
u=[x[1] for x in sub_cloudpoint]
muti_u[:,i]=u
i=i+1
cloudpoint[:,i]=muti_u.prod(1)
return cloudpoint
#可视化
res=twoDimensionforwardCloud(0,10,1,3,15,0.5,1000)
x=[x[0] for x in res]
y=[x[1] for x in res]
z=[x[2] for x in res]
fig=plt.figure()
ax=Axes3D(fig)
ax.scatter(x,y,z)
plt.show()
res=mutiForwardCloud([1,3],[10,15],[1,0.5],1000)
fig=plt.figure()
ax=Axes3D(fig)
ax.scatter(res[:,0],res[:,1],res[:,2])
plt.show()
def computeCloud1(x,y):#一维逆向云(方法一,需确定度)
i=0
while(i<len(y)):
if(y[i]>0.999):
del x[i]
del y[i]
i=i+1
x=np.array(x)
y=np.array(y)
Ex=np.mean(x)
En=np.zeros(x.shape)
for i in range(len(x)):
En[i]=np.abs(x[i]-Ex)/pow(-2*math.log(y[i],math.e),1/2)
En_1=np.mean(En)
He=np.sqrt(np.std(En))
return Ex,En_1,He
def computeCloud2(x):#一维逆向云发生器(方法二,无需确定度)
x=np.array(x);
Ex=np.mean(x);
En=np.sqrt(np.pi/2)*np.mean(np.abs(x-Ex))
S2=np.std(x)
He=np.sqrt(np.abs(S2*S2-En*En))
return Ex,En,He
res=forwardCloud(0,10,1,3000)
x=[x[0] for x in res]
y=[x[1] for x in res]
fig=plt.figure()
plt.scatter(x,y)
plt.show()
a,b,c=computeCloud1(x,y)
print(a,b,c)
a,b,c=computeCloud2(x)
print(a,b,c)