[simulations] improved univariate data exercise

This commit is contained in:
2019-12-18 10:19:33 +01:00
parent f0f757edad
commit 5e5ea9965c
3 changed files with 23 additions and 8 deletions

View File

@@ -1,10 +1,11 @@
% getting familiar with the randn() function:
randn(1, 3)
randn(3, 1)
randn(2, 4)
% simulate tiger weights:
mu = 220.0; % mean and ...
sigma = 30.0; % ... standard deviation of the tigers in kg
for n = [100, 10000]
fprintf('\nn=%d:\n', n)
for i = 1:5
@@ -12,3 +13,8 @@ for n = [100, 10000]
fprintf(' m=%3.0fkg, std=%3.0fkg\n', mean(x), std(x))
end
end
% plot the data:
plot(x(1:1000), 'o')
xlabel('Index')
ylabel('Weight [kg]')