이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to use "poissrnd" function?
조회 수: 22 (최근 30일)
이전 댓글 표시
Maria
2022년 10월 4일
Hello!
I'm trying to use "poissrnd" function in order to generate an arrival of task each minute. But i use a time frame in second.
lambda = 4;
v = poissrnd(lambda, 1, 3600);
with this command , i get an arrival each second, but i want the result "task/ min"
T=3600 and taux =1 s
lambda = 4 task/ min
i will be grateful if you could find me a solution! Thank you in advance
답변 (1개)
Torsten
2022년 10월 4일
편집: Torsten
2022년 10월 5일
lambda = 4
What is the unit of lambda ? Mean number of arrivals per minute ?
And you want to get a random vector for arrivals in each second ?
Note that the "3600" in the line
v = poissrnd(lambda, 1, 3600);
has nothing to do with time units (seconds in this case). It's only the number of random values "poissrnd" should return.
댓글 수: 25
Torsten
2022년 10월 4일
편집: Torsten
2022년 10월 4일
But if lambda= 4 tasks/min, you get random number of arrivals within each minute.
Or do I misunderstand something ?
lambda = 4;
v = poissrnd(lambda,10,1)
v = 10×1
4
2
5
4
8
3
9
1
5
4
For the first minute, you get 4 arrivals. For the next minute, you get 2 arrivals. And so on.
Maria
2022년 10월 4일
@Torsten i don't know if the sum is a good solution. i have do an arrival of task in each second but i though it is not logical solution. i need something more realistic so i have to change the arrival tasks each 60 second but saving the same period T=3600s.
this is my first result : with lambda=1/10 task/second, now i want to change lambda in each 60 second.
0 1 0 1 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 1 0 0 0
Torsten
2022년 10월 4일
편집: Torsten
2022년 10월 4일
this is my first result : with lambda=1/10 task/second, now i want to change lambda in each 60 second.
Here you get numbers of random arrivals for the next 10 seconds:
lambda = 0.1;
v = poissrnd(lambda,10,1).'
v = 1×10
0 0 0 0 0 0 0 1 0 0
Here you get numbers of random arrivals for the next 10 minutes:
lambda = 0.1*60;
v = poissrnd(lambda,10,1).'
v = 1×10
11 5 12 7 5 9 4 4 6 5
If you want to compare both, you have to generate 10*60 random arrivals for lambda = 0.1 and sum every 60 values of the vector v. Both methods simulate the same process:
lambda = 0.1;
v = poissrnd(lambda,10*60,1);
for i=1:10
w(i) = sum(v((i-1)*60+1:60*i));
end
w
w = 1×10
4 4 3 4 4 3 6 5 5 6
Maria
2022년 10월 4일
편집: Maria
2022년 10월 4일
@Torsten it seems that i can't explain the problem.
the row vector v should be equal to the period T, it means i will have 3600 columns, after each 60 columns i have a value.
for example
v[1 0 0 0........................................2 0 0 0.............................................5 0 0..................7 0 0......................]
this is v contains 3600 columns, the "1" is the arrival in the first instant t=1s
the "2" is the arrival after "60s"
the "5" is the arrival after "120s "
the "7" is the arrival after "180s" etc....
between this range the value was "0".
the arrival it may be "0" also.
Torsten
2022년 10월 4일
편집: Torsten
2022년 10월 4일
And what is the meaning of the 0's in between ? I can't make sense of it.
If the rate is 0.1 tasks/sec, then the 2,5,7 ... can be generated as
lambda = 0.1*60;
v = poissrnd(lambda,10,1);
v = cumsum(v)
v = 10×1
3
9
12
19
26
33
40
46
50
56
This gives you a random vector of arrivals within the first minute, the first 2 minutes, the first 3 minutes,...,the first 10 minutes.
Maria
2022년 10월 4일
편집: Maria
2022년 10월 4일
@Torsten because the arrival of tasks each 60 second so the interval between two 60s should get "0".
for example if i change to minutes , in each minute i have an arrival of task so the vector v will display values from column 1 to column 60.
but now i want to see the time in second, so every 60 second i will have a value. and the rest are zeros.
Torsten
2022년 10월 4일
because the arrival of tasks each 60 second so the interval between two 60s should get "0".
That's wrong. The arrivals happen within the time span of 60 seconds, not every 60 seconds.
Maria
2022년 10월 4일
@Torsten i will explain you by this example,
i put lambda=3 task/min
Period is 60 min , each column is 1 min
i get this V(1,60)
v [2 2 4 1 4 2 2 2 1 2 4 2 3 2 3 1 3 3 6 4 1 3 4 2 6 1 4 2 4 4 4 1 2 4 1 4 5 3 5 2 0 2 3 2 2 2 2 3 2 7 1 0 7 3 1 3 1 5 3 2]
now i want to save the same concept but when i change the time in second,
Period will be 3600s , each column is 1 sec, and lambda will be 3 task/60s.
so v will get values each 60 second.
if i can use any function to separate values with "0" and get 3600 columns ,no problem.
Torsten
2022년 10월 4일
편집: Torsten
2022년 10월 4일
I understand your point, but it's against the concept.
The v you obtain has not '0''s in between because the idea is that people not only arrive after 60 seconds, but every second. Thus an equivalent v for arrivals every second would be
lambda = 3/60;
v = poissrnd(lambda,1,3600)
v = 1×3600
0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Torsten
2022년 10월 4일
편집: Torsten
2022년 10월 4일
You start with a value at position 1, put 59 zeros. Then you are at position 60 with the last zero. The next value will be at position 61 and you put 59 zeros. You arrive at position 120. The next value will be at position 121 ...
v = rand(1,60);
v = [v;zeros(59,60)];
v = (v(:)).';
size(v)
ans = 1×2
1 3600
Torsten
2022년 10월 4일
편집: Torsten
2022년 10월 4일
And where is the third value ? If it were at position 119, it would be consistent because 60 - 1 = 119 - 60. If it were in position 120, the distance between second and first (59) compared to the distance between third and second (60) would be different.
But it's possible:
v = rand(1,60);
m = zeros(1,3600);
m(1) = v(1);
m((1:59)*60) = v(2:60);
Torsten
2022년 10월 4일
편집: Torsten
2022년 10월 4일
You already used all 60 for the other positions.
If you want a value at position 3600, v must be of size 61:
v = rand(1,61);
m = zeros(1,3600);
m(1) = v(1);
m((1:60)*60) = v(2:61);
All this confusion is unnecessary. The usual way is to put values at positions 1, 61, 121, ..., 3541. Then the distance between the non-zero elements is the same throughout the vector (60) and v has the usual size 1x60.
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
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 (한국어)