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

6 lines
223 B
Mathematica
Raw Permalink Normal View History

function P = CalculateProbMinMaxEq(min, max, total, experiences)
results = rand(total, experiences) > 0.5;
successes = sum(results) >= min;
successes = successes <= max;
P = sum(successes) / experiences;
end