Matlab 数据的高斯分块
我有一个简单的问题,如何对数据点进行高斯分类。假设在X=100时,我检测到5000个电子,但我的半高宽大约是4个点。在matlab中,是否有可能用以X=100为中心的高斯分布来存储5000个电子。比如X=99和X=101之间的2500个电子,95和105之间的5000个电子 听起来您在一个点上有一个测量(Matlab 数据的高斯分块,matlab,scaling,gaussian,binning,Matlab,Scaling,Gaussian,Binning,我有一个简单的问题,如何对数据点进行高斯分类。假设在X=100时,我检测到5000个电子,但我的半高宽大约是4个点。在matlab中,是否有可能用以X=100为中心的高斯分布来存储5000个电子。比如X=99和X=101之间的2500个电子,95和105之间的5000个电子 听起来您在一个点上有一个测量(X=100,e=5000),并且还知道半高宽的值(FWHM=4) 如果确实是这样,您可以这样计算sigma: sigma = FWHM/ 2/sqrt(2*log(2)); [N, binCt
X=100
,e=5000
),并且还知道半高宽的值(FWHM=4
)
如果确实是这样,您可以这样计算sigma
:
sigma = FWHM/ 2/sqrt(2*log(2));
[N, binCtr] = hist(sigma*randn(e,1) + X, Nbins);
% Example data
FWHM = 4;
e = 100000;
X = 100;
Nbins = 100;
% your std. dev.
sigma = FWHM/ 2/sqrt(2*log(2));
% Find where to start with the bin edges. That is, find the point
% where the PDF indicates that at most 1 electron is expected to fall
f = @(x, mu, sigma) exp(-0.5*((x-mu)/sigma).^2)/sigma/sqrt(2*pi);
g = @(y) quadgk(@(x)f(x,X,sigma), -inf, y)*e - 1;
h = fzero(g, X-FWHM*3);
% Create initial bin edges
binEdges = [-inf linspace(h, 2*X-h, Nbins-2) +inf];
% Bin electrons in batches
c = e;
done = false;
step = 5e3;
Nout = zeros(Nbins,1);
while ~done
% electrons still to be binned
c = c - step;
% Last step
if c <= 0
step = c+step;
c = 0;
done = true;
end
% Bin the next batch
N = histc(sigma*randn(step,1) + X, binEdges);
Nout = Nout + N;
end
% Bin edges must now be re-defined
binEdges =[...
2*binEdges(2)-binEdges(3),...
binEdges(2:end-1),...
2*binEdges(end-1)-binEdges(end-2)];
你可以这样做垃圾箱:
sigma = FWHM/ 2/sqrt(2*log(2));
[N, binCtr] = hist(sigma*randn(e,1) + X, Nbins);
% Example data
FWHM = 4;
e = 100000;
X = 100;
Nbins = 100;
% your std. dev.
sigma = FWHM/ 2/sqrt(2*log(2));
% Find where to start with the bin edges. That is, find the point
% where the PDF indicates that at most 1 electron is expected to fall
f = @(x, mu, sigma) exp(-0.5*((x-mu)/sigma).^2)/sigma/sqrt(2*pi);
g = @(y) quadgk(@(x)f(x,X,sigma), -inf, y)*e - 1;
h = fzero(g, X-FWHM*3);
% Create initial bin edges
binEdges = [-inf linspace(h, 2*X-h, Nbins-2) +inf];
% Bin electrons in batches
c = e;
done = false;
step = 5e3;
Nout = zeros(Nbins,1);
while ~done
% electrons still to be binned
c = c - step;
% Last step
if c <= 0
step = c+step;
c = 0;
done = true;
end
% Bin the next batch
N = histc(sigma*randn(step,1) + X, binEdges);
Nout = Nout + N;
end
% Bin edges must now be re-defined
binEdges =[...
2*binEdges(2)-binEdges(3),...
binEdges(2:end-1),...
2*binEdges(end-1)-binEdges(end-2)];
其中,N
是每个料仓中的电子量,binCtr
是料仓中心,Nbins
是要使用的料仓量
如果电子的数量变大,你可能会耗尽内存。在这种情况下,最好做同样的事情,但批量较小,如:
sigma = FWHM/ 2/sqrt(2*log(2));
[N, binCtr] = hist(sigma*randn(e,1) + X, Nbins);
% Example data
FWHM = 4;
e = 100000;
X = 100;
Nbins = 100;
% your std. dev.
sigma = FWHM/ 2/sqrt(2*log(2));
% Find where to start with the bin edges. That is, find the point
% where the PDF indicates that at most 1 electron is expected to fall
f = @(x, mu, sigma) exp(-0.5*((x-mu)/sigma).^2)/sigma/sqrt(2*pi);
g = @(y) quadgk(@(x)f(x,X,sigma), -inf, y)*e - 1;
h = fzero(g, X-FWHM*3);
% Create initial bin edges
binEdges = [-inf linspace(h, 2*X-h, Nbins-2) +inf];
% Bin electrons in batches
c = e;
done = false;
step = 5e3;
Nout = zeros(Nbins,1);
while ~done
% electrons still to be binned
c = c - step;
% Last step
if c <= 0
step = c+step;
c = 0;
done = true;
end
% Bin the next batch
N = histc(sigma*randn(step,1) + X, binEdges);
Nout = Nout + N;
end
% Bin edges must now be re-defined
binEdges =[...
2*binEdges(2)-binEdges(3),...
binEdges(2:end-1),...
2*binEdges(end-1)-binEdges(end-2)];
%示例数据
半高宽=4;
e=100000;
X=100;
Nbins=100;
%你的性病患者。
西格玛=FWHM/2/sqrt(2*log(2));
%找到从箱子边缘开始的位置。也就是说,找到重点
%其中PDF表示预计最多有1个电子下落
f=@(x,mu,sigma)exp(-0.5*((x-mu)/sigma)。^2)/sigma/sqrt(2*pi);
g=@(y)quadgk(@(x)f(x,x,sigma),-inf,y)*e-1;
h=f0(g,X-FWHM*3);
%创建初始箱子边
binEdges=[-inf-linspace(h,2*X-h,Nbins-2)+inf];
%分批存储电子
c=e;
完成=错误;
步骤=5e3;
努特=零(Nbins,1);
完成时
%电子仍然需要被储存
c=c-阶跃;
%最后一步
如果c,我想这听起来像我想做的。我有一个关于半高宽的近似概念,想把电子放在离散点的边界之间。我会试试这个,然后再打给你。非常感谢。如果这个数字真的很大呢。假设e=12345678。当我试图存储这么多数据时,我的matlab崩溃了。