|
|
Sample fixed number of rows from matrix at random interval within a range?
Hi,
I need help extracting a fixed number of rows from a matrix, at random intervals within a fixed range. I want to create a matrix that is a subsample of my original data matrix. The trick is that I want to select rows at random intervals between 9-19. For example, I would select row numbers
1 (+interval of 9)
10 (+interval of 18)
28 (+ interval of 10)
38 (+ interval of 12)
50 (+ interval of 9)
59 (+ another random interval between 9-19)
....
3000
Here's what I have:
data = Sim10spp % A 3000x10 data matrix
C = 8+(19-8)*rand(250,1); %creates 250x1 vector "C" of random numbers between 9-19, inclusive
Cround=ceil(C); %turn random numbers into integers
Random = data(1:Cround:3000,:); %Create new matrix "Random" by selecting rows from "data" at increments given by "Cround".
The problem with this code is that "Random" doesnt have a fixed number of rows; it varies in length, depending on which numbers are in "Cround". I need a matrix of 250 rows only, that samples from the entire 3000 rows of "data", including the first and last rows. So the first row selected for "Random" should be = 1, the last row should be = 3000, and the length of "Random" should be = 250.
Thanks!
|
|
0
|
|
|
|
Reply
|
Tessa
|
3/18/2011 8:50:23 PM |
|
On 3/18/2011 1:50 PM, Tessa wrote:
> Hi,
>
> I need help extracting a fixed number of rows from a matrix, at random intervals within a fixed range.
snip.
May be randi() is what you want, not rand()?
--Nasser
|
|
0
|
|
|
|
Reply
|
Nasser
|
3/18/2011 9:00:20 PM
|
|
|
1 Replies
453 Views
(page loaded in 0.033 seconds)
Similiar Articles: Sample fixed number of rows from matrix at random interval within ...Hi, I need help extracting a fixed number of rows from a matrix, at random intervals within a fixed range. I want to create a matrix that is a subs... how to generate random number in a fixed range - comp.soft-sys ...Sample fixed number of rows from matrix at random interval within ... Hi, I need ... extracting a fixed number of rows from a matrix, at random intervals within a fixed range. Random numbers in a specific interval - comp.soft-sys.matlab ...Random numbers in a specific interval - comp.soft-sys.matlab ... Numbers between a range - comp.lang.awk Sample fixed number of rows from matrix at random interval within ... Creating random decimal numbers in C - comp.soft-sys.matlab ...As far as I remember, it returns integers in the range ... Sample fixed number of rows from matrix at random interval within ... Creating random decimal numbers in C - comp ... how to choose random rows from a matrix - comp.soft-sys.matlab ...Sample fixed number of rows from matrix at random interval within ... I want to create a matrix that is a subsample of my original data matrix. Numbers between a range - comp.lang.awkRandom numbers in a specific interval - comp.soft-sys.matlab ... Numbers between a range - comp.lang.awk Sample fixed number of rows from matrix at random interval within ... Selecting random rows? - comp.databases.mysqlSample fixed number of rows from matrix at random interval within ... The trick is that I want to select rows at random intervals between 9-19. count rows - comp.lang.awkSample fixed number of rows from matrix at random interval within ... Hi, I need ... extracting a fixed number of rows from a matrix, at random intervals within a fixed range. Selecting a random sample in a query - comp.databases.ms-access ...Sample fixed number of rows from matrix at random interval within ... The trick is that I want to select rows at random intervals between 9-19. ... How to generate vector of random numbers in any interval (e.g. [-1 ...Sample fixed number of rows from matrix at random interval within ... How to generate vector of random ... interval (e.g. [-1 ..... to generate random number in a fixed range Sample fixed number of rows from matrix at random interval within ...Hi, I need help extracting a fixed number of rows from a matrix, at random intervals within a fixed range. I want to create a matrix that is a subs... Random Sampling in T-SQL - Microsoft Corporation: Software ...... random sample of rows isn't ... The row with the largest pure_random_number ... rows, .01 for a 1 percent sample, and 40 buckets. Consequently, each 2,500 interval range should ... 7/24/2012 9:06:56 PM
|
|
|
|
|
|
|
|
|