dimanche 27 septembre 2015

create a loop whith normrnd with given mus and sigmas

This is could be seen as an easy question but I could not figure out so far. I want to generate random number following a normal distribution, using given mus and sigmas, next round those numbers and eliminate the negatives. Finally store the created vectors in just one matrix called sim. The given mus and sigmas are the next ones: m1=22.06; s1=16.06; m2=23.84; s2=72.39; m3=3.79; s3=3.4; m4=148.306; s4=125.81; m5=36.82; s5=15.64; So far I have the next code:

for i = 1: 5 R(i) = normrnd(m(i),s(i),[m,n]);%generate random number ND R(i) = round(R(i)); [badrows,c]=find(R(i)<0);%find negatives ones newR(i) = R(setdiff(1:size(R(i),1),badrows),:);%eliminate them sim(:;i)= = newR(i); end I have tried the codes part by part and generate the random numbers, also round it and eliminates the negatives, but when I est the loop it has troubles calling the given numbers




Aucun commentaire:

Enregistrer un commentaire