http://www.mathworks.com/matlabcentral/newsreader/view_thread/319431
MATLAB Central Newsreader  Selecting subvectors and observations from original data to form samples
Feed for thread: Selecting subvectors and observations from original data to form samples
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Tue, 24 Apr 2012 05:39:13 +0000
Selecting subvectors and observations from original data to form samples
http://www.mathworks.com/matlabcentral/newsreader/view_thread/319431#874663
dhaskantha
Hi!<br>
<br>
I have a data, y=[379 357 390 376 376; 363 367 382 381 359; 401 402 407 402 396; 402 387 392 395 394; 415 405 396 390 395];<br>
This has 5 rows(5 subvectors in my case) and 5 columns. I am supposed to draw 5 subvectors WITH REPLACEMENT from the original data vector and then draw 5 observations WITH REPLACEMENT from each subvector obtained. This leads to a new sample of size 5x5. Can anybody help me out with this using MATLAB? Am I supposed to use randsample or datasample? <br>
Your help is much appreciated. Thank you.<br>
<br>
Regards,<br>
dhaskantha

Tue, 24 Apr 2012 06:07:11 +0000
Re: Selecting subvectors and observations from original data to form samples
http://www.mathworks.com/matlabcentral/newsreader/view_thread/319431#874666
Bruno Luong
"dhaskantha" wrote in message <jn5ea1$obe$1@newscl01ah.mathworks.com>...<br>
> Hi!<br>
> <br>
> I have a data, y=[379 357 390 376 376; 363 367 382 381 359; 401 402 407 402 396; 402 387 392 395 394; 415 405 396 390 395];<br>
> This has 5 rows(5 subvectors in my case) and 5 columns. I am supposed to draw 5 subvectors WITH REPLACEMENT from the original data vector and then draw 5 observations WITH REPLACEMENT from each subvector obtained. This leads to a new sample of size 5x5. <br>
<br>
r = ceil(5*rand(1,5))<br>
c = ceil(5*rand(1,5))<br>
z = y(r,c);<br>
<br>
% Bruno

Tue, 24 Apr 2012 06:15:14 +0000
Re: Selecting subvectors and observations from original data to form samples
http://www.mathworks.com/matlabcentral/newsreader/view_thread/319431#874667
Roger Stafford
"dhaskantha" wrote in message <jn5ea1$obe$1@newscl01ah.mathworks.com>...<br>
> Hi!<br>
> <br>
> I have a data, y=[379 357 390 376 376; 363 367 382 381 359; 401 402 407 402 396; 402 387 392 395 394; 415 405 396 390 395];<br>
> This has 5 rows(5 subvectors in my case) and 5 columns. I am supposed to draw 5 subvectors WITH REPLACEMENT from the original data vector and then draw 5 observations WITH REPLACEMENT from each subvector obtained. This leads to a new sample of size 5x5. Can anybody help me out with this using MATLAB? Am I supposed to use randsample or datasample? <br>
> Your help is much appreciated. Thank you.<br>
> <br>
> Regards,<br>
> dhaskantha<br>
        <br>
p = ceil(5*rand(1,5));<br>
z = y(p,:);<br>
q = bsxfun(@plus,[1:5].',5*floor(5*rand(5,5)));<br>
z = reshape(z(q),5,5);<br>
<br>
Roger Stafford

Tue, 24 Apr 2012 06:43:25 +0000
Re: Selecting subvectors and observations from original data to form samples
http://www.mathworks.com/matlabcentral/newsreader/view_thread/319431#874670
Bruno Luong
Obviously I and Roger read differently the problem:<br>
<br>
 to me the observationdraw is the same for all subvectors,<br>
 to Roger the observationdraw are different for each subvector.<br>
<br>
Up to you to choose what you need.<br>
<br>
Bruno

Tue, 24 Apr 2012 09:58:06 +0000
Re: Selecting subvectors and observations from original data to form samples
http://www.mathworks.com/matlabcentral/newsreader/view_thread/319431#874686
dhaskantha
Many thanks Bruno and Roger. I will try this out.<br>
<br>
Regards,<br>
dhaskantha

Wed, 25 Apr 2012 06:06:07 +0000
Re: Selecting subvectors and observations from original data to form samples
http://www.mathworks.com/matlabcentral/newsreader/view_thread/319431#874801
dhaskantha
Hi!<br>
<br>
I am able to generate one sample with the way you proposed. I am supposed to generate N samples like z from the original data y. How do I use the loop to do it? Is there a better way for me to do so? Thank you.<br>
<br>
Regards,<br>
dhaskantha<br>
<br>
>         <br>
> p = ceil(5*rand(1,5));<br>
> z = y(p,:);<br>
> q = bsxfun(@plus,[1:5].',5*floor(5*rand(5,5)));<br>
> z = reshape(z(q),5,5);<br>
> <br>
> Roger Stafford

Wed, 25 Apr 2012 20:30:22 +0000
Re: Selecting subvectors and observations from original data to form samples
http://www.mathworks.com/matlabcentral/newsreader/view_thread/319431#874881
Roger Stafford
"dhaskantha" wrote in message <jn848f$j9h$1@newscl01ah.mathworks.com>...<br>
> I am able to generate one sample with the way you proposed. I am supposed to generate N samples like z from the original data y.<br>
         <br>
p = bsxfun(@plus,ceil(5*rand(5,1,N)),5*floor(5*rand(5,5,N)));<br>
z = reshape(y(p),5,5,N);<br>
<br>
This should generate a threedimensional array z of size 5 x 5 x N with elements from y. Each of the slices z(:,:,k) from k = 1 to k = N should be a valid "sample" from y in accordance with the random selection procedure you described.<br>
<br>
(This assumes that my interpretation of what you wrote is correct. Bruno had a different interpretation of your words, so you should decide which is the one you want to use.)<br>
<br>
Roger Stafford

Thu, 26 Apr 2012 01:55:26 +0000
Re: Selecting subvectors and observations from original data to form samples
http://www.mathworks.com/matlabcentral/newsreader/view_thread/319431#874909
dhaskantha
Hi Roger!<br>
<br>
Thank you for your help. Will try working out using this method. <br>
<br>
Regards,<br>
dhaskantha<br>
<br>
<br>
"Roger Stafford" wrote in message <jn9msu$nri$1@newscl01ah.mathworks.com>...<br>
> "dhaskantha" wrote in message <jn848f$j9h$1@newscl01ah.mathworks.com>...<br>
> > I am able to generate one sample with the way you proposed. I am supposed to generate N samples like z from the original data y.<br>
>          <br>
> p = bsxfun(@plus,ceil(5*rand(5,1,N)),5*floor(5*rand(5,5,N)));<br>
> z = reshape(y(p),5,5,N);<br>
> <br>
> This should generate a threedimensional array z of size 5 x 5 x N with elements from y. Each of the slices z(:,:,k) from k = 1 to k = N should be a valid "sample" from y in accordance with the random selection procedure you described.<br>
> <br>
> (This assumes that my interpretation of what you wrote is correct. Bruno had a different interpretation of your words, so you should decide which is the one you want to use.)<br>
> <br>
> Roger Stafford