function x = Rayleigh_inv(P,muX)
% x = Rayleigh_inv(P,modeX)
% inverse CDF of Rayleigh distribution with mode modeX and probability P
 
%    Reference: http://en.wikipedia.org/wiki/Rayleigh_distribution

  idx = find(P<=0);	P(idx) = 0.0;
  idx = find(P>=1);	P(idx) = 1.0;

  modeX = muX * sqrt(2/pi); 
  
  x = modeX .* sqrt( -2.0 * log(1-P));

% ------------------------------------------------------------ Rayleigh_inv
