making permutations in row elements in a matrix

조회 수: 3 (최근 30일)
Ayse Kazan
Ayse Kazan 2013년 5월 11일
Hi all,
I have an nxm matrix. I need to make permutations but the row sums must be fixed.
Example;
Original matrix = [15 20; 10 30; 40 30; 50 10; 15 35]
row sums: 35,40,70,60,50.
One of the permutations; [10 25; 20 20; 50 20; 25 35; 20 30]
row sums: 35,40,70,60,50 (row sums must be fixed).
How can I generate permutations like this? Will permutation test work?
If I generate my original matrix with random numbers taken from a specific distribution , how can I permutate the row elements -with holding the row sums fixed-?
Thanks..

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 11일
편집: Azzi Abdelmalek 2013년 5월 11일
A=[15 20; 10 30; 40 30; 50 10; 15 35]
id1=A(:,1)/5
id2=A(:,2)/5
id=id1+id2
idx1=arrayfun(@(x) randi(x,1,1),id)
idx2=id-idx1
B=[idx1*5 idx2*5]
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 11일
The answer will be different, please do not change the question, post a new question
Ayse Kazan
Ayse Kazan 2013년 5월 11일
ok thank you so much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Prediction에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by