栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

凸集学习——理解凸集概念、凸包演示

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

凸集学习——理解凸集概念、凸包演示

凸集概念

设集合 S ∈ R n Sin R^n S∈Rn,如果对任意的 x 1 x 2 ∈ S x_1x_2in S x1​x2​∈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()

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/920781.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号