matlab双峰滤波,MATLAB中的单峰或双峰分布

这是一个使用Nic Price实施Hartigan’s Dip测试来识别单峰分布的脚本.棘手的一点是计算xpdf,它不是概率密度函数,而是一个有序的样本.

p_value是获得测试统计量的概率,至少与实际观察到的一样极端,假设零假设为真.在这种情况下,零假设是分布是单峰的.

close all; clear all;

function [x2, n, b] = compute_xpdf(x)

x2 = reshape(x, 1, prod(size(x)));

[n, b] = hist(x2, 40);

% This is definitely not probability density function

x2 = sort(x2);

% downsampling to speed up computations

x2 = interp1 (1:length(x2), x2, 1:1000:length(x2));

end

nboot = 500;

sample_size = [256 256];

% Unimodal

sample2d = normrnd(0.0, 10.0, sample_size);

[xpdf, n, b] = compute_xpdf(sample2d);

[dip, p_value, xlow, xup] = HartigansDipSignifTest(xpdf, nboot);

figure;

subplot(1,2,1);

bar(n, b)

title(sprintf('Probability of unimodal %.2f', p_value))

% Bimodal

sample2d = sign(sample2d) .* (abs(sample2d) .^ 0.5);

[xpdf, n, b] = compute_xpdf(sample2d);

[dip, p_value, xlow, xup] = HartigansDipSignifTest(xpdf, nboot);

subplot(1,2,2);

bar(n, b)

title(sprintf('Probability of unimodal %.2f', p_value))

print -dpng modality.png

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值