Hi Given that I have a matrix, say A = [1 2 3; 4 5 6], how do I draw new samples over the range of A columns using uniform distribution? For example, min(:,1) = 1 and max(:,1) = 4 Therefore my new sample can have data points ranging from 1 to 4 in the first column, and so on. I know I can use rand to draw random numbers that is uniformly distributed, but I do not know how to set a range for each column of the matrix. I would really appreciate any help given. Thank you very much in advance. Sincerely Mit 

Uniform sampling with min and max
Started by ●July 2, 2001
Reply by ●July 2, 200120010702
First, create a matrix B having enough random numbers (distributed between 0 and 1.0). I'm doing 100 per column: M = 100; N = size(A,2); B = rand(M,N); Now multiply each column of B by the range indicated by the columns of A: B = B*diag( A(2,:)  A(1,:) ); Now the random numbers in the jth column of B are from 0 to (A(2,j)  A(1,j)). This is the correct differential range, but since the range should actually be A(1,j) to A(2,j), we must move the range up by A(1,j). B = B + ones(M,1)*A(1,:) B should now be your desired matrix. Sincerely, Glen Ragan 
Reply by ●July 2, 200120010702
hi Mit, u can use the following command: ones(size(A))*diag(min(A)) + rand(size(A))*diag((max(A)  min(A))) in the second term the "diag((max(A)  min(A)))" scales each column separately according to the required range. In the first term "diag(min(A))" adds the required bias. To use the same for rows use premultiplication instead of postmult. priyank  wrote: > Hi > > Given that I have a matrix, say A = [1 2 3; 4 5 6], > how do I draw new samples over the range of A columns using uniform > distribution? > > For example, min(:,1) = 1 and max(:,1) = 4 > Therefore my new sample can have data points ranging from 1 to 4 in > the first column, and so on. I know I can use rand to draw random > numbers that is uniformly distributed, but I do not know how to set a > range for each column of the matrix. > > I would really appreciate any help given. Thank you very much in > advance. > > Sincerely > Mit > > __________________________________________________ 