设集合 S ∈ R n Sin R^n S∈Rn,如果对任意的 x 1 x 2 ∈ S x_1x_2in S x1x2∈S,和任意 λ ∈ [ 0 , 1 ] lambdain[0,1] λ∈[0,1],都有 λ x 1 + ( 1 − λ ) x 2 ∈ S lambda x_1+(1-lambda)x_2in S λx1+(1−λ)x2∈S,那么说 S S S是一个凸集。
凸包概念设 x 1 , x 2 , . . . , x m ∈ R n x_1,x_2,...,x_min R^n x1,x2,...,xm∈Rn, λ i ∈ [ 0 , 1 ] , i = 1 , 2 , . . . , m lambda_iin [0,1],i=1,2,...,m λi∈[0,1],i=1,2,...,m满足 λ 1 + λ 2 + λ 3 + . . . + λ m = 1 lambda_1+lambda_2+lambda_3+...+lambda_m=1 λ1+λ2+λ3+...+λm=1,那么说 x 1 λ 1 + x 2 λ 2 + . . . + x m λ m x_1lambda_1+x_2lambda_2+...+x_mlambda_m x1λ1+x2λ2+...+xmλm是 x 1 , x 2 , . . . , x m x_1,x_2,...,x_m x1,x2,...,xm的一个凸包。
程序演示就二维点集来说,如果一个集合是凸集,那么集合内任意任意两点连成的直线上任意两点都在集合内。
任意个点的凸包是包围所有点的面积最小的区域。
import matplotlib.pyplot as plt
import numpy as np
x1=np.array([0,0])
x2=np.array([1,1])
x3=np.array([10,5])
set=[]
index=np.arange(0,1,0.01)
for index_1 in index:
for index_2 in index:
index_3=1-index_1-index_2
if index_3<0:
continue
point=index_1*x1+index_2*x2+index_3*x3
set.append(point)
x=[]
y=[]
for point in set:
x.append(point[0])
y.append(point[1])
plt.scatter(x,y)
# plt.scatter(x1[0],x1[1])
# plt.scatter(x2[0].x2[1])
# plt.scatter(x3[0],x3[1])
plt.scatter(0,0,c=(1,0,0))
plt.scatter(10,5,c=(1,0,0))
plt.scatter(1,1,c=(1,0,0))
plt.show()



