The body of your "for" loop does not involve "i" except as the index to store the value. The variable "fff" that you are calculating does not involve "i" and there are no changes in the loop to any variable that you are calculating from. Therefore the value of "fff" and "ff" that you calculate each loop is the same. Therefore you can calculate them outside the loop.
Inside the loop you are essentially doing a "find" operation, counting the number of items before the random value is le ff. You can vectorize that.
YY = sum(bsxfun(@gt, rand(ns,1), ff.'));
It is not immediately obvious to me that the final value in ff is 1.0; it is not obvious to me that it could not be greater than or less than 1.0 . It is therefor not clear that rand() is proper here. If it is, then if the distribution has an infinite tail, you appear to be truncating the distribution at 100. It is not obvious that is justified numerically.
If you do decide to expand to a wider range for qqq, then you will have the ultimate limit that rand() cannot produce any value between (1-2^(-53)) and 1 because there simply are no representable double precision numbers in that range . On the lower end of the scale, most of the random number generators cannot produce a rand() value less than 2^(-53). There is, however, one random number generator that can produce any finite double precision number (including greater than 1), but you would need to select it specifically.