help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extracting random elements from an array


From: James Sherman Jr.
Subject: Re: Extracting random elements from an array
Date: Mon, 18 Apr 2011 12:04:22 -0400

On Mon, Apr 18, 2011 at 4:44 AM, shay <address@hidden> wrote:
yes i do need replacement but thats not a problem thx James, yes I do need
more than 1 value from both a and b, i just need to make sure that if I
concatenate them it will always extract at least one value from each array.


No, it will just treat the whole array as one and randomly pick from that.  Like Francesco said, you need to be careful with your problem statement.  Just so I'm completely sure, the output of your code that you want is:
10 elements randomly picked with replacement from arrays a, b, and c, where at least 1 element is from array a, and at least 1 element is from array b.

If so, I'd just do the following:
pick 1 from a
pick 1 from b
pick 8 from the concatenation of a, b, and c


reply via email to

[Prev in Thread] Current Thread [Next in Thread]