Machine learning assignment 4

This commit is contained in:
2017-05-16 22:11:33 +01:00
parent 18453d2e37
commit a9cee6e867
18 changed files with 246 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
function binary = sample_bernoulli(probabilities)
global report_calls_to_sample_bernoulli
if report_calls_to_sample_bernoulli,
fprintf('sample_bernoulli() was called with a matrix of size %d by %d. ', size(probabilities, 1), size(probabilities, 2));
end
seed = sum(probabilities(:));
binary = +(probabilities > a4_rand(size(probabilities), seed)); % the "+" is to avoid the "logical" data type, which just confuses things.
end