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1
0
0
1
0
0
1
]'

m = 100;
k = [0:1:5];
p = 0.5;
intentos = [alan; efrain; paco; angel; eva];
exitos = sum(intentos, 'r');
n(1) = sum(exitos == 0)
n(2) = sum(exitos == 1)
n(3) = sum(exitos == 2)
n(4) = sum(exitos == 3)
n(5) = sum(exitos == 4)
n(6) = sum(exitos == 5)

f(1) = n(1) / m;
f(2) = n(2) / m;
f(3) = n(3) / m;
f(4) = n(4) / m;
f(5) = n(5) / m;
f(6) = n(6) / m;

plot(k, f, 'r.', 'MarkerSize', 20)
a=gca();
a.data_bounds=[-1 0;6 0.5];
xgrid
xlabel('Numero de exitos')
ylabel('Frecuencia relativa')
title('Frecuencia y funcion de masa de lanzamiento de monedas')
legends(['lanzamientos(m) = 100';'Eventos = 0 a 5';'Probabilidad individual (p) = '],[-1, -1, -1], opt=1 )

//b(x, n, p) = b(k, 5, 0.5)
for i = 1:6
    binomial(i) = (factorial(5) / (factorial(5 - k(i)) .* factorial(k(i)))) * (p)^k(i) * (1-p)^(5 - k(i))
end
plot(k, binomial, 'k.', 'MarkerSize', 20)
