相关疑难解决方法(0)

加速用于FDR估计的MATLAB代码

我有2个输入变量:

  • 带有N个元素的p值(p)向量(未排序)
  • 和N × M矩阵,其具有通过随机排列(pr)以M次迭代获得的p值.N非常大,10K到100K或更多.M让我们说100.

我正在估计每个元素的错误发现率(FDR),p表示如果当前p值(来自p)将是阈值,来自随机排列的p值将经过多少.

我写与ARRAYFUN的功能,但它需要大量的时间用于大N(2 分钟为Ñ = 20K),媲美的for循环.

function pfdr = fdr_from_random_permutations(p, pr)
%# ... skipping arguments checks
pfdr = arrayfun( @(x) mean(sum(pr<=x))./sum(p<=x), p);
Run Code Online (Sandbox Code Playgroud)

任何想法如何让它更快?

关于统计问题的评论也欢迎.

测试数据可以生成为p = rand(N,1); pr = rand(N,M);.

performance matlab vectorization

3
推荐指数
2
解决办法
457
查看次数

Matlab编码的说明

我在互联网上找到了这个Matlab代码.它实际上是整个代码的一部分,可以在这里找到.有人可以逐行解释发生了什么.我真的很绝望......

% ------------- % This is code to make the edge detecting filter % ----%
function filter=gaussfilt(N)

% calculate alpha so the filter fills all N points
alpha=N;
first=-(1-N/2)*exp(-(1-N/2)^2/alpha);
count=0;
while first<.1*(-(1530/4000*N-N/2)*exp(-(1530/4000*N-N/2)^2/alpha))
    count=count+1;
    alpha=N*500*count;
    first=-(1-N/2)*exp(-(1-N/2)^2/alpha);
end

for n=1:N
     filter(n)=-(n-N/2)*exp(-(n-N/2)^2/alpha);   % d/dt of a gaussian
end
filter=filter/sum(abs(filter));     % normalization

return
Run Code Online (Sandbox Code Playgroud)

matlab

0
推荐指数
2
解决办法
862
查看次数

标签 统计

matlab ×2

performance ×1

vectorization ×1