vendredi 30 septembre 2016

normrnd of MATLAB generating different values for the same setting

I do not know how to describe the problem so I titled it like that. If you have any better idea, please fix it. I apologize in advance.

My problem came up with when I was writing a code using normal random generator of MATLAB.

clear all; 
clc; 
close all;
rng(0,'twister');

sigma=50; 
mean(normrnd(10,sigma,20,1))

n=20;
mean(normrnd(10,sigma,n,1))

When I generate 20 normally-distributed numbers while controlling it by setting generator to Mersenne Twister and seed to 0, I can use that code that I provided above. I can write the sample size inside the normrnd function or I can define it out of function but when you run it and find the means of generated numbers for both ways, you will also release that they differ greatly. Such first mean is 43.2294 and the second mean is 7.1280. Does anyone have any idea about this situation?




Aucun commentaire:

Enregistrer un commentaire