uaveiro-leci/3ano/1semestre/mpei/aula02/part1/CalculateProbEqual.m

5 lines
189 B
Mathematica

function P = CalculateProbEqual(partial, total, experiences)
results = rand(total, experiences) > 0.5;
successes = sum(results) == partial;
P = sum(successes) / experiences;
end