I'm trying to prove that P(Xi) = lim (ni/n) when n->00. I'm trying to simulate a coin toss n times and count the number of tails and plot the resulting frequence f=numoftails/n for different values of n. I get empty plots though and I have no idea what I'm doing wrong.
I have tried several different implementations, none of which seem to work, I will show you my last one:
n = 100
maxn = 1000
f = zeros (1,maxn-n) %initializing
while n < maxn
numoftails = 0; %iniztializing
for c = 1:n
temp = unidrnd(2) % 1 will be head, 2 will be tails
if temp == 1
numoftails = numoftails + 1 %counting the tails
end
end
f(n-99) = numoftails / n %frequency of tails for each n
plot (f(n-99)) %I use f(n-99) so when I start from 100 I start filling from f(1)
n = n + 1
end

