Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: random number generator from logistic distribution
Date: Wed, 30 Jan 2008 00:59:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 30
Message-ID: <fnoi4m$b4q$1@fred.mathworks.com>
References: <fnod3l$po$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1201654742 11418 172.30.248.37 (30 Jan 2008 00:59:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 30 Jan 2008 00:59:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:448224


"Jessica " <jandre@mathworks.com> wrote in message <fnod3l$po
$1@fred.mathworks.com>...
> Hi,
> I'm trying to create a random number generator from the 
> logistic distribution. Does the following function look 
> right or am I completely off track?!
> 
> r=lrnd(m,n,mu,sigma)
> p=rand(m,n)
> r=log(p./(1-p)).*sigma+mu
> 
> Thanks for your help
> 
> Jess
--------
  That looks good to me, except that of course functions are written this way:

 function  r=lrnd(m,n,mu,sigma);
 etc.

You have correctly taken the inverse of the cumulative distribution function:

 p = F(x;mu,sigma) = 1/(1+exp(-(x-mu)/sigma))

  Note: Since sigma is a scalar, you don't need the dot when multiplying by it:

  r=log(p./(1-p))*sigma+mu;

Roger Stafford