gpt4 book ai didi

c++ - 在 C++ 中将正态分布拟合到直方图

转载 作者:行者123 更新时间:2023-11-28 06:14:12 25 4
gpt4 key购买 nike

我正在使用 C++ 进行频谱感知,到目前为止我的问题是如何估计噪声的准确值。所以我做了我的数据的直方图,我想为这个直方图拟合一个高斯分布,然后我得到这个拟合分布的平均值,就像在 matlab [mean,variance]=normfit(x) 中一样。

vec noise::gauss_fit(vec spectrum_sensed,int Nfft)
{
Histogram<double> hist;
hist.setup(min(spectrum_sensed),max(spectrum_sensed),Nfft);
// now I need to fit this histogram by a normal distribution "Normal"
// and finally I get the mean of this distribution: normal.get_setup();
}

在此先感谢您的帮助!

最佳答案

正态分布使这很容易:

mean = sum(spectrum_sensed)/N

variance = sum((spectrum_sensed-mean)^2)/N

您拟合的不是直方图,而是数据。在正态分布的情况下,不涉及任何拟合,因为一切都是分析性的。

关于c++ - 在 C++ 中将正态分布拟合到直方图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30639841/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com