tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,2 @@
mu = 1; sd = 0.5;
x = randn(1000,1) * sd + mu;

View file

@ -0,0 +1 @@
x = normrnd(mu, sd, [1000,1]);

View file

@ -0,0 +1,15 @@
function randNum = randNorm(mu0,chi2, sz)
radiusSquared = +Inf;
while (radiusSquared >= 1)
u = ( 2 * rand(sz) ) - 1;
v = ( 2 * rand(sz) ) - 1;
radiusSquared = u.^2 + v.^2;
end
scaleFactor = sqrt( ( -2*log(radiusSquared) )./ radiusSquared );
randNum = (v .* scaleFactor .* chi2) + mu0;
end

View file

@ -0,0 +1,5 @@
>> randNorm(1,.5, [1000,1])
ans =
0.693984121077029