拟合高斯分布到数据

时间:2015-07-21 09:51:16

标签: matlab normalization curve-fitting gaussian

我有一个包含1440个值(值介于0-1之间)的向量y,看起来像一个高斯分布。 因此,我想找到最合适的高斯分布来建立模型。

x=1:1440;
[sigma_,mu_] = gaussfit(x,y);
norm = normpdf(x,mu_,sigma_);

我的问题是,规范中的值比y中的值小,即norm中的值的大小为10-3,而y中的值介于0 1之间1}}。

然后我要添加一个额外的步骤,以便在0和1之间标准化规范中的值。

norm_data = (norm - min(norm)) / ( max(norm) - min(norm) );

我的手术是否正确? (估计sigma和mu,normpdf,归一化) 有没有办法直接拟合表达概率的原始数据?

y可以下载here

2 个答案:

答案 0 :(得分:1)

假设你正在使用这个gaussfit,如果你检查函数的头部:

% REMARKS:
% The function does not always converge in which case try to use initial
% values sigma0, mu0. Check also if the data is properly scaled, i.e. p.d.f
% should approx. sum up to 1

这意味着在装配之前,您需要确保sum(y)==1+err犯错误。

y sum(y) 470.1964 1,远离y。规范化您的数据,使其在拟合之前等于1。

修改

如果数据不是(或多或少,它接受0.5-1.5范围内的数据),那么确实会正常化。而且效果很好。由于norm在函数内进行了规范化,如果您要将结果yy进行比较,则需要对norm进行规范化或对 % normalize y plot(x,norm,x,y./sum(y)) % denormalize norm plot(x,norm*sum(y),x,y) 进行归一化。

from scapy.all import *

def packet_handler(pkt) :
    # if packet has 802.11 layer, and type of packet is Data frame
    if pkt.haslayer(Dot11) and pkt.type == 0:
            # do your stuff here
            print(pkt.show())


sniff(iface="wlan0mon", prn=packet_handler)

在任何一种情况下(但规模不同):

enter image description here

答案 1 :(得分:0)

gaussfit(x,y)拟合数据的归一化高斯。如果您的数据未规范化,则无法使用。如何恰当地适应它的问题已经回答here