From: Peter Perkins on
Mohammed Khalilia wrote:

> Since randsample takes only vectors for the data and the weight, I had to reshape a
> a1 = reshape(a,1,8);
> w1 = reshape(w,1,8);
> y=randsample(a1,8,true,w1);

This is not "produc[ing] a bootstrap replicate of the original data according to the probability W for every instance". You're giving each separate _value_ a weight, and resampling them individually. I would think you would want to resample rows, i.e., "instances".
From: Mohammed Khalilia on
Peter Perkins <Peter.Perkins(a)MathRemoveThisWorks.com> wrote in message <hf3eut$jt2$1(a)fred.mathworks.com>...
> Mohammed Khalilia wrote:
>
> > Since randsample takes only vectors for the data and the weight, I had to reshape a
> > a1 = reshape(a,1,8);
> > w1 = reshape(w,1,8);
> > y=randsample(a1,8,true,w1);
>
> This is not "produc[ing] a bootstrap replicate of the original data according to the probability W for every instance". You're giving each separate _value_ a weight, and resampling them individually. I would think you would want to resample rows, i.e., "instances".

You are correct, I need to resample rows (instances). Here is the exact problem:
"Produce a bootstrap replicate of the original data set according to the probability W for
every instance i by resampling with replacement from the original data set."

Initial probability W = 1/N where N is number of instances, W is 1xN vector.

I think the solution provided by Lorenzo Guerrasio make sense (Thanks Lorenzo).

a = [1 2;5 6;7 8;34 5];
w = [0.25 0.25 0.25 0.25]; % This was wrong above, it was 4x2 matrix
ind=1:size(a,1);
n_sample=4;
Rind=randsample(ind,n_sample,true,w);
new_sample=a(Rind,:);
From: Lorenzo Guerrasio on
note that if w=1/N and n_sample is equal to the element of a, than the easiest thing to do is to use bootstrp
[mist, Sindex]=bootstrp(1,[],a);
newsample=a(Sindex,:);




"Mohammed Khalilia" <mohammedsk(a)gmail.com> wrote in message <hf3ljo$g5t$1(a)fred.mathworks.com>...
> Peter Perkins <Peter.Perkins(a)MathRemoveThisWorks.com> wrote in message <hf3eut$jt2$1(a)fred.mathworks.com>...
> > Mohammed Khalilia wrote:
> >
> > > Since randsample takes only vectors for the data and the weight, I had to reshape a
> > > a1 = reshape(a,1,8);
> > > w1 = reshape(w,1,8);
> > > y=randsample(a1,8,true,w1);
> >
> > This is not "produc[ing] a bootstrap replicate of the original data according to the probability W for every instance". You're giving each separate _value_ a weight, and resampling them individually. I would think you would want to resample rows, i.e., "instances".
>
> You are correct, I need to resample rows (instances). Here is the exact problem:
> "Produce a bootstrap replicate of the original data set according to the probability W for
> every instance i by resampling with replacement from the original data set."
>
> Initial probability W = 1/N where N is number of instances, W is 1xN vector.
>
> I think the solution provided by Lorenzo Guerrasio make sense (Thanks Lorenzo).
>
> a = [1 2;5 6;7 8;34 5];
> w = [0.25 0.25 0.25 0.25]; % This was wrong above, it was 4x2 matrix
> ind=1:size(a,1);
> n_sample=4;
> Rind=randsample(ind,n_sample,true,w);
> new_sample=a(Rind,:);
From: Mohammed Khalilia on
"Lorenzo Guerrasio" <lorenzo.guerrasio(a)email.it> wrote in message <hf3mfu$bl1$1(a)fred.mathworks.com>...
> note that if w=1/N and n_sample is equal to the element of a, than the easiest thing to do is to use bootstrp
> [mist, Sindex]=bootstrp(1,[],a);
> newsample=a(Sindex,:);
>
>
>
>
> "Mohammed Khalilia" <mohammedsk(a)gmail.com> wrote in message <hf3ljo$g5t$1(a)fred.mathworks.com>...
> > Peter Perkins <Peter.Perkins(a)MathRemoveThisWorks.com> wrote in message <hf3eut$jt2$1(a)fred.mathworks.com>...
> > > Mohammed Khalilia wrote:
> > >
> > > > Since randsample takes only vectors for the data and the weight, I had to reshape a
> > > > a1 = reshape(a,1,8);
> > > > w1 = reshape(w,1,8);
> > > > y=randsample(a1,8,true,w1);
> > >
> > > This is not "produc[ing] a bootstrap replicate of the original data according to the probability W for every instance". You're giving each separate _value_ a weight, and resampling them individually. I would think you would want to resample rows, i.e., "instances".
> >
> > You are correct, I need to resample rows (instances). Here is the exact problem:
> > "Produce a bootstrap replicate of the original data set according to the probability W for
> > every instance i by resampling with replacement from the original data set."
> >
> > Initial probability W = 1/N where N is number of instances, W is 1xN vector.
> >
> > I think the solution provided by Lorenzo Guerrasio make sense (Thanks Lorenzo).
> >
> > a = [1 2;5 6;7 8;34 5];
> > w = [0.25 0.25 0.25 0.25]; % This was wrong above, it was 4x2 matrix
> > ind=1:size(a,1);
> > n_sample=4;
> > Rind=randsample(ind,n_sample,true,w);
> > new_sample=a(Rind,:);

W = 1/N is only the initial value, then W will change in every iteration.