Difference between rng('shuffle') and NO rng for estimating with MLE
조회 수: 19 (최근 30일)
이전 댓글 표시
I am trying to estimate a 3-parameter weibul distribution with random numbers. But I dont understand the difference between rng('shuffle') and NO rng('shuffle'), I mean deleting the line. Both lines estimates random numbers in my code. Can someone tell me the difference?
And if you can give me any advice for my code for estimating a 3-parameter weibul estimation, I would appreciate that.
clear all
n = 1000;
t0 = 0.5;
b_A = 1:5;
T_A = 1:5;
LowerBound= [0 0 0];
rng('shuffle');
data = zeros(n,length(b_A),length(T_A));
params = zeros(length(b_A),length(T_A));
data2P = zeros(n,length(b_A),length(T_A));
params2p = zeros(length(b_A),4,length(T_A));
for k= T_A
for i= b_A
data(:,i,k) = wblrnd(i,k, [n,1]) + t0;
data2P(:,i,k) = wblrnd(b_A(i),T_A(k), [n,1]);
start = [i k t0];
custompdf = @(x,a,b,c) (x>c).*(b/a).*(((x-c)/a).^(b-1)).*exp(-((x-c)/a).^b);
opt = statset('MaxIter',1e5,'MaxFunEvals',1e5,'FunValCheck','off');
params(i,1:3,k) = mle(data(:,i,k),'pdf',custompdf,'start',start,'Options',opt,'LowerBound',LowerBound,'UpperBound',[Inf Inf min(data(:,i,k))])
params(i,4,k) = i;
params(i,5,k) = k;
params(i,6,k) = t0;
params2p(i,1:2,k) = wblfit(data2P(:,i,k));
params2p(i,3,k) = i;
params2p(i,4,k) = k;
end
end
댓글 수: 1
Rik
2020년 12월 7일
Please do not delete your question. If you feel this is a beginner question: there are many beginners, so be nice to them. They might come across your question and learn from it.
채택된 답변
the cyclist
2020년 6월 21일
If you start a fresh instance of MATLAB, and generate a sequence of pseudorandom numbers, it will always be the same sequence. (Try it!)
If you do not use the
rng('shuffle')
then you will get the numbers from that sequence. If you do use it, then instead of traveling along that predetermined sequence of numbers, you will leap to a different point on that sequence, based on the time when you make the call to the function.
댓글 수: 8
the cyclist
2020년 6월 21일
Sorry, I did not mean to make you feel bad.
--------
"Initializes generator based on the current time, resulting in a different sequence of random numbers after each call to rng."
--------
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!