Do anyone know if there is a Matlab function available
that generates Rayleigh distributed random numbers? Is it
perhaps part of the communications toolbox, does anyone
know?
Sincerely yours,
Jonas Gamalielsson, RF engineer, Allgon Mobile Communications
>I think you can generate numbers with a Rayleigh by taking two independent
>Gaussian number generator.
>Here two line of Matlab code to generate 1000 numbers:
>x=randn(1000,2);
>y=sqrt(x(:,1).^2+x(:,2).^2);
I think it would be more efficient to do something like
x=rand(1000,1);
y=sqrt(-2*log(x));
as uniform random numbers are cheaper than Gaussians, and certainly
cheaper that two Gaussians. I have not tested this though.
The Matlab documentation does say that rand returns uniform deviates
on (0,1) which I would interpret as NOT containing 0 or 1. This would
imply that there is no x==0 case to catch, but you may want to play it
safe.
>You can see the distribution by:
>hist(y);
>Hope this help.
>--
>Leo Montreuil
Dr Andrew McLean DERA Winfrith
Advanced Concepts Team Winfrith Technology Centre
Sonar Systems Department Dorchester, Dorset DT2 8XJ
United Kingdom
e-mail : almc...@dra.hmg.gb
tel : +44 (0)1305 212428 DERA is an Agency of the MOD
fax : +44 (0)1305 212107
In the STATISTICS TOOLBOX there is function named "raylrnd", which
supposedly generates pseudo random numbers from RAYLEIGH distribution. I
also saw some other functions for computing CDF, Inverse CDF, PDF and one
for calculating the Mean and Standard deviation of this probability
distribution.
Out of curiosity what are trying to model? I have seen people use
this distribution to approximate location errors in a Cartesian coordinate
system, where the two coordinates each have a Gaussian error associated
with them.
Regards,
H.K.
jonas.gamalielsson <jonas.gam...@swipnet.se> wrote in article
<33433C...@swipnet.se>...
x=randn(1000,2);
y=sqrt(x(:,1).^2+x(:,2).^2);
You can see the distribution by:
hist(y);
Hope this help.
--
Leo Montreuil
(for correct EMAIL remove word "SPAM" from my return address)