Resampling from cumulative probability distribution [message #58349] |
Sat, 26 January 2008 06:09 |
Klemens
Messages: 18 Registered: April 2007
|
Junior Member |
|
|
Hallo together,
I am computing a bootstrap analysis where the resampling routine from
a cumulative probability distribution needs the most cpu time. May be
you have some ideas how to eliminate the loop and speed up the
routine ...
function get_bootstrap_pdf, np, cdf
zz = randomu(S, np) ; np is the number of
samples
cdfa = cdf[0:n_elements(cdf)-2] ; cdf is the cumulative
probability distribution
cdfb = cdf[1:n_elements(cdf)-1]
b = fltarr(n_elements(cdf)) ; b will be the
resampled distribution
b[*] = 0.00
for i = 0, n_elements(cdf)-2 do begin ;
loop through all bins
index = where((zz ge cdfa[i]) and (zz lt cdfb[i]))
if (max(index) ge 0) then begin
b[i] = n_elements(index)
endif else begin
b[i] = 0.00
endelse
endfor
total_b = total(b)
b = b / total(b)
return, b
end
Thanks for your help in advance !
Klemens
|
|
|