% Copying and distribution of this file, with or without modification,
% are permitted in any medium without royalty provided this notice is
% preserved.  This file is offered as-is, without any warranty.
%
% If you modify it and use it with MATLAB (that is proprietary), please
% check compatibility with GNU Octave (that is free/libre software).


function matrix = random_stochastic_matrix_in_columns(nb_lines,
						      nb_columns,
						      fill_percentage = 0.1)
  matrix = zeros(nb_lines, nb_columns);
  nb_lines_filled = ceil(nb_lines * fill_percentage);
  value = 1.0 / nb_lines_filled;
  for column = 1 : nb_columns -1
    for a = 1 : nb_lines_filled
      line = random_null_line_in_column_of_matrix_2d(matrix, column);
      matrix(line, column) = value;
    end
  end
end
