
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

function p = exp_fraction (x, threshold) % %Input: x an array (assumed to have at least one entry) % threshold a real value. % %Output: p the fraction of the components of x satisfying % exp( x(i)) >= threshold % n = 0; for i = 1: length(x) if (exp(x(i)) >= threshold) n = n+1; end end p = n/length(x);
function p = exp_fraction (x, threshold) % % …. (same comments as above) % p = sum (exp(x) >= threshold)/length(x);
function p = exp_fraction (x, threshold) % %Input: x an array (assumed to have at least one entry) % threshold a real value (default value is zero). % %Output: p the fraction of the components of x satisfying % exp( x(i)) >= threshold % if (nargin == 1) t = 0; else t = threshold; p = sum (exp(x) >= t)/length(x);