Re: Random number generator



In article <m3zmpvit9s.fsf@xxxxxxxxxxxxxxxxxxxxxx>, Peter Boettcher
<boettcher@xxxxxxxxxx> wrote:

> "Anindo Roy" <anindoroy1975@xxxxxxxxx> writes:
>
> > Hi all,
> >
> > I wanted to find out if any of the pseudo-random number generator
> > functions in MATLAB (e.g. rand, randn, etc) can be modified to solve
> > the following problem:
> >
> > Generate a sequence of (pseudo) random numbers each of which is
> > bounded between "a" and "b" where "a", "b" are known and fixed
> > scalars.
> >
> > I don't care about the distribution of the random numbers as long as
> > each element belongs to the interval (a,b).
>
> How about the distribution x_n=a? They're all in the interval
> a<=x_n<=b. Surely you must have SOME requirements for the
> distribution...
>
> Knowing that rand outputs numbers between 0 and 1, think about
> possible transformations to apply to those numbers that would give you
> what you want...
> --
> Peter Boettcher <boettcher@xxxxxxxxxx>
-------------------------------------------------
Hello Anindo,

Peter is right. You really do need to have some idea of the
distribution within [a,b]. If you want them uniformly distributed, just
do this

x = (b-a)*rand(1,n) + a

There are a great many other possibilities.

(Remove "xyzzy" and ".invalid" to send me email.)
Roger Stafford
.



Relevant Pages

  • Re: Random number generator
    ... > I wanted to find out if any of the pseudo-random number generator ... > functions in MATLAB can be modified to solve ... > I don't care about the distribution of the random numbers as long as ... Knowing that rand outputs numbers between 0 and 1, ...
    (comp.soft-sys.matlab)
  • Re: random lottery draw funciton
    ... from approximately 18,000 shares. ... I believe rand() uses your operating system's default randsystem call, ... the quality of the pseudo-random numbers depends on your system. ... http://www.andyhsoftware.co.uk/space:: disk and FTP usage analysis tool ...
    (comp.lang.php)
  • Re: question about random generator
    ... >> The C Standard specifies that randgenerates pseudo-random numbers, ... >> the intention is that the numbers be uniform but that may be debatable. ... > anything about the distribution of the numbers. ...
    (comp.lang.c)
  • Re: Random Number Generation Dialog Box
    ... > distribution. ... A help search tells me about what looks like a wonder dialog ... Be aware, however, that the ATP's pseudorandom number generator is not ... XL01's RAND() ...
    (microsoft.public.mac.office.excel)
  • Re: question about random generator
    ... The rand() function generates uniformly distributed ... distribution because doing so would require a lot of fairly ... matter -- certainly not a topic for the Standard to explicate. ... that it means "sort of uniform-ish in a sort of hand-waving way, ...
    (comp.lang.c)