<div dir="ltr"><div><div><div><div><div><div><div><div>Not sure if thefollowing mimics R's 'sample' function<br><br>undef("resample")<br>function resample(N[1]:integer, method[1]:integer, opt[1] )<br>
;<br>; simple function to generate indices<br>; N = sample size<br>;<br>; method = 0 ==> sample *without* replacement; reshuffle the order <br>; mean/std/... unchanged<br>; use when the order of sampling is important<br>
;<br>; method = 1 ==> sample *with* replacement<br>; mean/std/... will change<br>;<br>; opt = 0 ==> currently not used<br>local k<br>begin<br> if (method.eq.0) then <br>
k = generate_unique_indices( N ) <br> else<br> k = round(random_uniform(-0.499999,N-0.500001,N), 3)<br> end if`<br><br> return(k)<br></div>end<br><br>++++++++++++++++++++++++++<br><br></div><div>let x(*), N=dimsizes(x)<br>
</div><div><br></div> <br></div> i = resample(N, 1, 0) ; resample with replacement<br><br></div> xr = x(i)<br><br></div>or, directly<br><br></div> xr = x(resample(N, 1, 0) )<br><br></div>let z(K,M,N)<br>
<br></div><div> zr = z<br></div><div><br></div><div> do k=0,K-1<br></div><div> do m=0,M-1<br></div><div> zr(k,m,:) = z(k,m,i)<br></div><div> end do<br></div><div> end do<br></div><div>
<div><div><div><div><div><br> <br></div></div></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 27, 2014 at 3:45 PM, debasish mazumder <span dir="ltr"><<a href="mailto:debasish@ucar.edu" target="_blank">debasish@ucar.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi<br>
Is there any function in NCL that can be used for resampling of an array<br>
(like sample function in R).<br>
<br>
with regards<br>
-Deb<br>
<br>
<br>
_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br></div>