Matérn硬核点过程(MHCPP),二维坐标

最近需要对车队进行建模,在二维坐标下先生成散点图,然后在将点的y坐标设置为恒定。这里给出的代码是二维坐标下的散点图。参考的代码放在最后辣。

clc;clear
lambda = 100;                       % 密度
M = 0;
U = unifrnd(0,1);

while U >= exp(-lambda)           %判定条件
   U = U*unifrnd(0,1);
   M=M+1;
end 

if M < 1
   M = 1;
end

L = 100;
a = 0;b = L;      %取[0,100]*[0,100]*[0,100]的布点区域;
c = 0;d = L;
A = zeros(1,M);
B = zeros(1,M);
for i = 1:M 
    U1 = unifrnd(0,1);
    A(i) = (b-a)*U1;
    U2 = unifrnd(0,1);
    B(i) = (d-c)*U2;
    plot(A(i),B(i),'r^');
    hold on;
end
grid on;
Hppp=[A;B];
%% step2 标记点
mark=unifrnd(0,1,1,M); % 对应于Hppp矩阵,0到1之间,1行M列
[marknew,index]=sort(mark);  %Matlab中给一维向量排序是使用sort函数: sort (X),其中x为待排序的向量。若欲保留排列前的索引,则可用[sX,index] = sort(X),
%排序后,sX是排序好的向量,index是 向量sX中对X的索引。事实上这里X=sX(index), [X恒等于
%sX(index)],

for i=1:length(mark)
    newmatrix(:,i)=Hppp(:,index(i)); %index(i)表示index矩阵中第i个元素
end
figure (1) % newmatrix 为排序后的矩阵
subplot(1,2,1) %一个FIGURE图形生成一行两列两个子图,subplot(1,2,1)后面一个1表示当前激活第1个子图。
scatter(newmatrix(1,:),newmatrix(2,:),'r^') 
title('(a) HPPP')
grid on;
%% 计算两点之间的距离
%参考 https://zhidao.baidu.com/question/432651512409955044.html
distance=zeros(length(mark),length(mark));
for i=1:length(mark)
for j=i+1:length(mark)
 distance(i,j)=sqrt(sum((newmatrix(:,i)-newmatrix(:,j)).^2)); %计算列与列间欧式几何距离
end
end
distance=distance+distance'; %b应该是对角矩阵,上边循环只计算一半,这里补另一半

%% step3距离判别

disth=8; % 判决门限
j=1; interindex=0;
indexpoint=ones(1,length(mark));%生成1行length(mark)列的全1矩阵
dis=(distance>=disth);

for i=1:length(mark)
    for j=i+1:length(mark)
        if indexpoint(i)==1
            if dis(i,j)==0
                indexpoint(j)=0;
            end
        end
    end
end
temp=find(indexpoint==1)
           
%% Mhcpp画图
for t=1:length(temp)
    Mhcpp(:,t)=newmatrix(:,temp(t));
end
subplot(1,2,2)
scatter(Mhcpp(1,:),Mhcpp(2,:),'r^')
title('(b) MHCPP with disth=8')
grid on;
hold on

 

参考:

1.随机几何--Matern硬核点过程(Matern hard core point process,MHCPP)_王有福的博客-CSDN博客_matern核

2.PPP相关-泊松簇过程PCP-matlab程序_weixin_38206454的博客-CSDN博客

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值