function val = quniform(dosample,var, limit)
% Proposal distribution used in sampling methods
%
% x = quniform(1, N,limit)
%     It returns the samples, according to the uniform distribution
%     N: number of samples
%     limit: range of the samples
% q = quniform(0, x,limit)
%     It evaluetes the samples, according to the uniform distribution
%     x: sample values
%     limit: range of the samples

% APRENDIZAJE AUTOMÁTICO (G. Pajares y J. M. de la Cruz, Eds.)
% Editorial: RA-MA
% Capítulo 7 y 8: Monte Carlo I y II
% Autores: Eva Besada-Portas, Sergey M. Plis

 

if dosample,
    N=var;
    x = rand(1,N) * diff(limit)+limit(1);
    val=x;
else
    x=var;
    r=ones(size(var))/diff(limit);
    r(var<limit(1))=0;
    r(var>limit(2))=0;
    val=r;
end
