이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to change the rng value
조회 수: 1 (최근 30일)
이전 댓글 표시
code:
unused_rows=1:6
while ~isempty(unused_rows)
N_UE_rows=2;
rng(3)
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
The above code works how to run the code by having different numbers of rng say for example rng(12),rng(2),rng(1).
댓글 수: 1
Steven Lord
2018년 5월 1일
Prabha, you've asked this same question or a slight variation several times now. It's still not clear to me exactly what you're trying to do. Please take a short break from coding and write out IN WORDS NOT CODE a description of what you're trying to do. Explain it as though you were explaining it to someone who has no idea what problem you're trying to solve. That may help us understand your ultimate goal and allow us to suggest more effective solutions to that problem.
채택된 답변
Walter Roberson
2018년 3월 21일
list_of_rng_seeds = [12, 2, 1];
rng_usage_idx = 0;
unused_rows = 1:6;
while ~isempty(unused_rows)
N_UE_rows = 2;
rng_usage_idx = mod(rng_usage_idx, length(list_of_rng_seeds)) + 1;
rng(rng_usage_idx);
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
댓글 수: 28
Prabha Kumaresan
2018년 3월 21일
but i can view the result for one rng value how to view the result for rng=2,rng=3,rng=12 .
Prabha Kumaresan
2018년 3월 21일
could you help me how to use the rng values in for loop so that for each run different values of rng can be used.
Steven Lord
2018년 3월 21일
Why are you resetting the random number generator in each iteration of your while loop? Are you doing so to compare the results that you receive from those specific seeds? Or are you doing so because you think that makes it "more random"? In the latter case, the recommendation is to NOT reset the generator.
Prabha Kumaresan
2018년 3월 23일
I want to compare the results that i receive from those specific seeds.
Walter Roberson
2018년 3월 23일
list_of_rng_seeds = [12, 2, 1];
num_rng = length(list_of_rng_seeds);
for rng_usage_idx = 1 : num_rng
this_seed = list_of_rng_seeds(rng_usage_idx);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows = 1:6;
while ~isempty(unused_rows)
N_UE_rows = 2;
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
end
Prabha Kumaresan
2018년 3월 23일
thanks now i can get the output for list of rng seeds. could you help me how to combine the rows of 12,2,1 separately,as i need to calculate the throughput value of 12,2,1.
Walter Roberson
2018년 3월 23일
Your code has no output as such. You overwrite all of your variables for each iteration of the loop. The only reason to execute your code is to display the results to the screen.
Prabha Kumaresan
2018년 3월 28일
편집: Walter Roberson
2018년 3월 28일
I would like to check with you the following code
list_of_rng_seeds = [12, 2, 1];
num_rng = length(list_of_rng_seeds);
for rng_usage_idx = 1 : num_rng
this_seed = list_of_rng_seeds(rng_usage_idx);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows = 1:6;
while ~isempty(unused_rows)
N_UE_rows = 2;
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
end
In the code the number of rows for each rng is getting fixed, say for example for rng=1 ,(34) and (12) form groups. I would like to check how to have variable numbers such that (3),(2),and (14) for rng.
Walter Roberson
2018년 3월 28일
I am not sure why you say that for rng 1, that (34) and (12) form groups? Did you mean (36) and (12) ? See below.
"I would like to check how to have variable numbers such that (3),(2),and (14) for rng"
I am not sure what you are asking, but I suspect what you are referring to is that the number of rows obtained at first is always 2. That is because you assigned N_UE_rows = 2 instead of determining the number of rows randomly. If I recall correctly, somewhere around your 171's question in Answers you were randomly determining the number of rows selected -- back then it was just a matter that the way you were selecting, it was lower probability that N_UE_rows would be well distributed.
Below results are for rng = 1
rows =
3 6
idx =
3 6
unused_rows =
1 2 4 5
rows =
1 2
idx =
1 2
unused_rows =
4 5
rows =
4 5
idx =
1 2
Prabha Kumaresan
2018년 4월 5일
편집: Walter Roberson
2018년 4월 5일
i would like to check the following code:
list_of_rng_seeds = [12, 2, 1];
num_rng = length(list_of_rng_seeds);
for rng_usage_idx = 1 : num_rng
this_seed = list_of_rng_seeds(rng_usage_idx);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows = 1:6;
while ~isempty(unused_rows)
N_UE_rows = 2;
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
end
could you please help me to run the above code with respect to different list_of_rng_seeds=[3 4 5 6 7],[8 9 10 11 12 13].
Walter Roberson
2018년 4월 5일
lists_of_rng_seeds = {[12, 2, 1], [3 4 5 6 7],[8 9 10 11 12 13]};
for seed_idx = 1 : length(lists_of_rng_seeds)
list_of_rng_seed = lists_of_rng_seeds{seed_idx};
num_rng = length(list_of_rng_seeds);
for rng_usage_idx = 1 : num_rng
this_seed = list_of_rng_seeds(rng_usage_idx);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows = 1:6;
while ~isempty(unused_rows)
N_UE_rows = 2;
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
end
end
Prabha Kumaresan
2018년 4월 5일
I am getting Error using fprintf Function is not defined for 'cell' inputs. Error in line fprintf('Below results are for rng = %d\n', this_seed);
Could you help me to overcome it.
Walter Roberson
2018년 4월 5일
list_of_list_of_seeds = {[12, 2, 1], [3 4 5 6 7],[8 9 10 11 12 13]};
for seed_idx = 1 : length(list_of_list_of_seeds)
list_of_rng_seeds = list_of_list_of_seeds{seed_idx};
num_rng = length(list_of_rng_seeds);
for rng_usage_idx = 1 : num_rng
this_seed = list_of_rng_seeds(rng_usage_idx);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows = 1:6;
while ~isempty(unused_rows)
N_UE_rows = 2;
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
end
end
Prabha Kumaresan
2018년 4월 5일
편집: Walter Roberson
2018년 4월 5일
I also want to use include the command
N_UE_rows=ceil(sqrt(randi([2,numel(unused_rows)])));
N_UE_rows=ceil(sqrt(randi([numel(unused_rows)])));
in addition to
N_UE_rows = 2;
such that [12, 2, 1] make use of
N_UE_rows = 2;
[3 4 5 6 7] need to use
N_UE_rows=ceil(sqrt(randi([2,numel(unused_rows)])));
and [8 9 10 11 12 13] need to use
N_UE_rows=ceil(sqrt(randi([numel(unused_rows)])));
could you please help me on this.
Walter Roberson
2018년 4월 5일
determine_N_UE_rows{1} = @(unused_rows) 2;
determine_N_UE_rows{2} = @(unused_rows) ceil(sqrt(randi([2,numel(unused_rows)])));
determine_N_UE_rows{3} = @(unused_rows) N_UE_rows=ceil(sqrt(randi([numel(unused_rows)])));
list_of_list_of_seeds = {[12, 2, 1], [3 4 5 6 7],[8 9 10 11 12 13]};
for seed_idx = 1 : length(list_of_list_of_seeds)
list_of_rng_seeds = list_of_list_of_seeds{seed_idx};
N_UE_rows_fun = determine_N_UE_rows{seed_idx};
num_rng = length(list_of_rng_seeds);
for rng_usage_idx = 1 : num_rng
this_seed = list_of_rng_seeds(rng_usage_idx);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows = 1:6;
while ~isempty(unused_rows)
N_UE_rows = N_UE_rows_fun(unused_rows);
rows = unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
end
end
Prabha Kumaresan
2018년 4월 5일
편집: Prabha Kumaresan
2018년 4월 9일
could you please help me to include list_of_list_of_seeds to calculate the throughput and run with different iterations with respect to the following command line
output1(t,r)=overall_throughput1;
output1_it(t,r,it)=output1(t,r);
where t=6 and r=8.
I want to include list_of_list_of_seeds with respect to the above command line.
Could you please help me on this.
Prabha Kumaresan
2018년 4월 6일
Could you please help me how to calculate the throughput for [12, 2, 1],[3 4 5 6 7],[8 9 10 11 12 13] separately as i need to plot the graph for each throughput in one graph.
I tried with the code given to calculate the throughput followed by plotting the graph.
determine_N_UE_rows{1} = @(unused_rows) 2;
determine_N_UE_rows{2} = @(unused_rows) ceil(sqrt(randi([2,numel(unused_rows)])));
determine_N_UE_rows{3} = @(unused_rows) N_UE_rows=ceil(sqrt(randi([numel(unused_rows)])));
list_of_list_of_seeds = {[12, 2, 1], [3 4 5 6 7],[8 9 10 11 12 13]};
for seed_idx = 1 : length(list_of_list_of_seeds)
list_of_rng_seeds = list_of_list_of_seeds{seed_idx};
N_UE_rows_fun = determine_N_UE_rows{seed_idx};
num_rng = length(list_of_rng_seeds);
for rng_usage_idx = 1 : num_rng
this_seed = list_of_rng_seeds(rng_usage_idx);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows = 1:6;
while ~isempty(unused_rows)
N_UE_rows = N_UE_rows_fun(unused_rows);
rows = unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
end
end
throughput=........;
dummyX = 1:length(N_rng);
figure
plot(dummyX,y,'rs');
hold on;grid on;
But I am unable to get the throughput result separately.Could you please help me on this
Walter Roberson
2018년 4월 9일
Prabha Kumaresan, you have asked over 200 questions. You have had plenty of time to learn to understand the basics of for loops.
Go heavy into cell arrays if you need to. The first rule of programming is to get it to work first and only then worry about optimizing it.
Prabha Kumaresan
2018년 4월 9일
Ok.I have tried with the following code with respect to four iterations. output1(t,seed_idx,s,r)=overall_throughput1; output1_it(t,seed_idx,s,r,it)=output1(t,seed_idx,s,r); But the output1_it remains the same for all the iterations.Could you please help me on this.
Prabha Kumaresan
2018년 5월 1일
with respect to the code given i want to include some commands onto it.
N_UE=[4 6 8]
for t=1:length(N_UE)
list_of_list_of_seeds = {[12, 2, 1], [3 4 5 6 7],[8 9 10 11 12 13]};
for seed_idx = 1 : length(list_of_list_of_seeds)
list_of_rng_seeds = list_of_list_of_seeds{seed_idx};
num_rng = length(list_of_rng_seeds);
for rng_usage_idx = 1 : num_rng
this_seed = list_of_rng_seeds(rng_usage_idx);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows = 1:N_UE(t);
while ~isempty(unused_rows)
N_UE_rows = 2;
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
end
end
end
Could you please help me how to select when N_UE=4,list_of_list_of_seeds=[12,2,1] N_UE=6,list_of_list_of_seeds=[3,4,5,6,7] N_UE=8,list_of_list_of_seeds=[8,9,10,11,12,13]
Prabha Kumaresan
2018년 5월 2일
ok. N_UE=4
the following results should be
Below results are for rng = 12
rows =
3
rows =
1 4 2
Below results are for rng = 2
rows =
1 4
rows =
2 3
Below results are for rng = 1
rows =
2 4
rows =
1 3
N_UE=6
Below results are for rng = 3
rows =
6 2
rows =
1
rows =
5
rows =
4 3
Below results are for rng = 4
rows =
5 1 4
rows =
2
rows =
3 6
Below results are for rng = 5
rows =
2 4
rows =
5 3
rows =
1 6
Below results are for rng = 6
rows =
3 4 1
rows =
2 6 5
Below results are for rng = 7
rows =
5
rows =
4 6
rows =
3 1 2
N_UE=8
the following result should be
Below results are for rng = 8
rows =
5 4 7
rows =
2 1
rows =
3 8 6
Below results are for rng = 9
rows =
5
rows =
1
rows =
3 6
rows =
7
rows =
4 2 8
Below results are for rng = 10
rows =
1 8 6
rows =
5
rows =
4
rows =
3 2 7
Below results are for rng = 11
rows =
4 1
rows =
2 8
rows =
7 5
rows =
6 3
Below results are for rng = 12
rows =
6 3
rows =
2 5 7
rows =
4 8 1
Below results are for rng = 13
rows =
1 5 6
rows =
2 4
rows =
8 3 7
Could you please help me on this.
Prabha Kumaresan
2018년 5월 7일
편집: Walter Roberson
2018년 5월 7일
With respect to the code given
unused_rows=1:6
while ~isempty(unused_rows)
N_UE_rows=2;
rng(3)
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
Could you please help me how to write the algorithm for it.
Prabha Kumaresan
2018년 5월 7일
편집: Walter Roberson
2018년 5월 7일
with respect to the code given
list_of_list_of_seeds = {[12, 2, 1], [3 4 5 6 7],[8 9 10 11 12 13]};
for seed_idx = 1 : length(list_of_list_of_seeds)
list_of_rng_seeds = list_of_list_of_seeds{seed_idx};
num_rng = length(list_of_rng_seeds);
for rng_usage_idx = 1 : num_rng
this_seed = list_of_rng_seeds(rng_usage_idx);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows = 1:6;
while ~isempty(unused_rows)
N_UE_rows = 2;
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
end
end
could you please help me how to write the algorithm for it.
Walter Roberson
2018년 5월 7일
I am not sure what you mean by "write the algorithm for it" ? Are you asking for something like a flow chart? Are you asking for pseudocode to write into project documentation ?
None of the people who has been volunteering to respond to your questions are able to write the pseudocode for that, because not one of us has been able to understand why you want to keep setting the random seed.
Walter Roberson
2018년 5월 7일
Flow charts are usually fairly straight forward to write once you have the code. I find reference to a commercial tool http://www.aivosto.com/visustin.html which can generate flow charts from MATLAB. See also https://stackoverflow.com/questions/5518200/automatically-generating-a-diagram-of-function-calls-in-matlab
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Repeated Measures and MANOVA에 대해 자세히 알아보기
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
