I want to estimate random numbers with the weibull distribution.
1.) "wblrnd" generates random numbers of my function "custompdf". So do "rng ('shuffle')".
In "results" I can see my results. When I run my code(without changing it), it displays random numbers.
When I I delete the line with rng ('shuffle'), it also display random numbers.
So whats the difference?
2.) Someone helped me to storage my code for a better overview and for flexibilty of "b" and "T" (In case I change them)
Its the line beginning with "results". It works really nice, but I dont really understand the line. Can someone explain what the line is doing? I am really a noob in Matlab.
clear all;n = 100;t0 = 0.5;b = 1:3;T = 1:3;rng ('shuffle')for v_T= T for v_b= b data(:,v_b,v_T) = wblrnd(v_b,v_T, [n,1]) + t0; start = [1 0 0]; custompdf = @(x,a,b,c) (x>c).*(b/(a-c)).*(((x-c)/(a-c)).^(b-1)).*exp(-((x-c)/(a-c)).^b); opt = statset('MaxIter',1e3,'MaxFunEvals',1e3,'FunValCheck','off'); params(v_b,1:3,v_T) = mle(data(:,v_b,v_T),'pdf',custompdf,'start',start,'Options',opt,'LowerBound',[0 0 0],'UpperBound',[Inf Inf min(data(:,v_b,v_T))]) params(v_b,4,v_T) = v_b; params(v_b,5,v_T) = v_T; params(v_b,6,v_T) = t0; params(v_b,7,v_T) = n; end results((v_T-1)*length(b)+1:v_T*length(b), 1:size(params, 2)) = params(:,:,v_T);end
Best Answer