From: "Bruno Luong" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Weighted random number generator
Date: Tue, 22 Jul 2008 09:21:03 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 21
Message-ID: <g648pv$drr$>
References: <g647ip$2d5$>
Reply-To: "Bruno Luong" <>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1216718463 14203 (22 Jul 2008 09:21:03 GMT)
NNTP-Posting-Date: Tue, 22 Jul 2008 09:21:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: comp.soft-sys.matlab:480858

"stinkinrich88 Coombez" <> wrote in
message <g647ip$2d5$>...

> Is there any function I can use to do this? Or a function
> that gives me random numbers (between 0-1) using a formula
> that I specify?

If you want to generate random variable X having pdf 'f'
(f>=0, integral f = 1), then do the following:

X = g(rand)

where g is the inverse of the cumulative integral of f, i.e.,

g(y) is a number such that
y = integral on [-inf,g(y)] f(t) dt