%MATLAB notes from 11-5-2010
clear all
%law of large numbers
rand
hist(rand(1,100),10)
hist(rand(1,1000),10)
hist(rand(1,10000),10)
hist(rand(1,100000),10)
hist(rand(1,1000000),10)
hist(rand(1,10000000),10)
mean(rand(1,1000))
mean(rand(1,1000000))
var(rand(1,1000))
1/12
var(rand(1,1000))
var(rand(1,1000000))
%central limit theorem
for n = 1:1000
g(n) = mean(rand(1,100000));
end
hist(g,50)
mean(g)
var(g)
sqrt(ans)
%adding Gaussian noise to signals
s = zeros(1,100);
s(51) = 1;
noise = randn(1,100)*.1; %independent
snoisy = s+noise;
plot(s)
plot(snoisy)
noise = ones(1,100)*randn; %not independent!