From: rynn on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hmmdbi$d67$1(a)canopus.cc.umanitoba.ca>...
> rynn wrote:
> > Hi,
> >
> > Can anyone help me on how to generate random number with this condition:-
> > 1) I have 100 data and want to select 10 sample. However, I have to
> > repeat choosing the 10 sample for 30 times.
>
> With or without replacement for each trial?
>
> If it is without replacement, then:
>
> [a,b] = sort(rand(100,30));
> selectedsamples = samples(b(1:10,:));
>
> Each column will be the samples for one trial. (I put them into columns
> because you probably want to access a trial at a time and access along columns
> is faster in Matlab.)
>
> > 2) the model that I want to develop here is nonlinear model with 1
> > output and 4 input variables (x1,x2,x3,x4). So I got confusing about
> > which variables or only output data that I have to use in order to
> > generate a random sample.
>
> It is not clear how the second part of your question relates to the first
> part? Is the probability of selection of particular samples non-uniform? If so
> then with or without replacement??

Hi,
I'm sorry for the 2nd question, just ignore that.
Back to the 1st question, the 10 samples are randomly selected with replacement for 30sets and I don't want a similar number is repeated in each set. for example [1 1 2 3 4 5 6 6 7 8]. How can I do this..?

thank you..
From: Walter Roberson on
rynn wrote:
> Walter Roberson <roberson(a)hushmail.com> wrote in message
> <hmmdbi$d67$1(a)canopus.cc.umanitoba.ca>...
>> rynn wrote:

>> > 1) I have 100 data and want to select 10 sample.

> Back to the 1st question, the 10 samples are randomly selected with
> replacement for 30sets and I don't want a similar number is repeated in
> each set. for example [1 1 2 3 4 5 6 6 7 8]. How can I do this..?

Your chances of getting a duplicate value are significantly increased if you
use selection with replacement. If you draw 10 values out of 100 with
replacement, then chances are over 37% that you will draw at least one
duplicate. If the values must not be duplicated, then by definition the
overall result must be end up as if you had drawn without replacement, so you
might as well take the more efficient approach of drawing without replacement
anyhow. Or is this an assignment in which you have been instructed to draw
"with replacement" ?

Question: the 100 values that you are sampling from: are there potentially
duplicates amongst them, and so it needs to be checked in case you drew a
duplicate value from a different position? If so, then I take it you would
like the probability of selecting any one value to be proportional to the
number of times it appears? e.g., if you half of the numbers were 0 and you
were drawing 5 values, then you would want there to be only a 1 in 2^5 chance
that 0 was not drawn ? As opposed to taking the unique values of the dataset
and drawing uniformly from those (which would give a 26% chance of not having
drawn a 0 in 5 draws if the other 50 of 100 samples were distinct.)
From: Richard Willey on
Statistics Toolbox has a nice function called randsample.

You have the option to sample with or without replacement.


"rynn " <rina_0990(a)yahoo.co.uk> wrote in message
news:hmlfjd$jdn$1(a)fred.mathworks.com...
> Hi,
>
> Can anyone help me on how to generate random number with this condition:-
> 1) I have 100 data and want to select 10 sample. However, I have to repeat
> choosing the 10 sample for 30 times.
> 2) the model that I want to develop here is nonlinear model with 1 output
> and 4 input variables (x1,x2,x3,x4). So I got confusing about which
> variables or only output data that I have to use in order to generate a
> random sample.
>
> Thanks in advance..
>
> rynn.