Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!nx01.iad01.newshosting.com!newshosting.com!198.186.194.250.MISMATCH!news-out.readnews.com!news-xxxfer.readnews.com!postnews.google.com!27g2000hsf.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: random sample
Date: Thu, 12 Jun 2008 04:17:20 -0700 (PDT)
Organization: http://groups.google.com
Lines: 8
Message-ID: <0552cab7-b53e-4473-ad6a-02413d924362@27g2000hsf.googlegroups.com>
References: <g2qovm$jp$1@fred.mathworks.com>
NNTP-Posting-Host: 75.186.67.199
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1213269440 21836 127.0.0.1 (12 Jun 2008 11:17:20 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 12 Jun 2008 11:17:20 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: 27g2000hsf.googlegroups.com; posting-host=75.186.67.199; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 
Xref: news.mathworks.com comp.soft-sys.matlab:473458



On Jun 12, 5:07=A0am, "wang wang" <pli...@gmail.com> wrote:
> Hi,everyone~How to generate a random sample from a
> specific density function using matlab?
-----------------------------------------------------
Short answer: construct the cumulative distribution function of your
desired distribution y=3Dcdf(x).  Then "invert" it to get x=3D"cdf-1"(y),
then plug in a y gotten from the rand() function to get an x that
would be as if it were generated from your desired pdf.