[ncl-talk] resampling
Dennis Shea
shea at ucar.edu
Wed Aug 27 20:08:26 MDT 2014
Not sure if thefollowing mimics R's 'sample' function
undef("resample")
function resample(N[1]:integer, method[1]:integer, opt[1] )
;
; simple function to generate indices
; N = sample size
;
; method = 0 ==> sample *without* replacement; reshuffle the order
; mean/std/... unchanged
; use when the order of sampling is important
;
; method = 1 ==> sample *with* replacement
; mean/std/... will change
;
; opt = 0 ==> currently not used
local k
begin
if (method.eq.0) then
k = generate_unique_indices( N )
else
k = round(random_uniform(-0.499999,N-0.500001,N), 3)
end if`
return(k)
end
++++++++++++++++++++++++++
let x(*), N=dimsizes(x)
i = resample(N, 1, 0) ; resample with replacement
xr = x(i)
or, directly
xr = x(resample(N, 1, 0) )
let z(K,M,N)
zr = z
do k=0,K-1
do m=0,M-1
zr(k,m,:) = z(k,m,i)
end do
end do
On Wed, Aug 27, 2014 at 3:45 PM, debasish mazumder <debasish at ucar.edu>
wrote:
> Hi
> Is there any function in NCL that can be used for resampling of an array
> (like sample function in R).
>
> with regards
> -Deb
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140827/be197709/attachment.html
More information about the ncl-talk
mailing list