Just to finish the discussion with a useful result.
from the chapter 7 of:
Link to online-Version: http://www.library.cornell.edu/nr/cbookcpdf.html
respectively the mentioned chapter: http://www.library.cornell.edu/nr/bookcpdf/c7-4.pdf
A very simple and efficient
unsigned long idum = 0;
...
idum = 1664525L*idum + 1013904223L;
Varuzhan
----- Original Message -----
From: Marko Pavlin
To: lpc2000@yahoogroups.com
Sent: Tuesday, May 03, 2005 3:23 PM
Subject: Re: [lpc2000] rand() function
Hello!
I found TEA very useful as random number generator.
http://www.simonshepherd.supanet.com/tea.htm
Marko
Paul Curtis wrote:
> Hi,
>
> > The standard rand() function of many compilers (Keil, etc.)
> > return pseudorandom integer in range 0 to 32767.
> > 1. Is the period of such pseudorandom generators equal to
> > 2^15, or it is more?
>
> Good question. Usually these implementations are based on linear
> congruence, i.e next_random = (seed*x+y) modulo a smaller number.
>
> > 2. Who has an efficient algorithm for 2^31 period rand()
> > function? Both assembler and C realizations are of interest.
>
> Try Google, there are many PRANGs. It really depends upon your
> application what type of PRANG to employ e.g. uniform random numbers,
> Gaussian random numbers, and so on. Higher quality random numbers
> usually require more expensive computations and are, therefore, less
> efficient.
>
> As with implementation of transcendental and logarithmic approximations,
> there is more than one way to skin a cat, so just consider rand() a
> low-quality function that fulfils the requirements of the ISO standard.
>
> Boost has an appealing random number library:
>
> http://www.boost.org/libs/random/
>
> --
> Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> CrossWorks for MSP430, ARM, AVR and (soon) MAXQ processors
>
> ------------------------------------------------------------------------
> *Yahoo! Groups Links*
>
> * To visit your group on the web, go to:
> http://groups.yahoo.com/group/lpc2000/
>
> * To unsubscribe from this group, send an email to:
> lpc2000-unsubscribe@yahoogroups.com
> <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
------------------------------------------------------------------------------
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/lpc2000/
b.. To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]Message
SPAM[Spam 1.0] Re: [lpc2000] rand() function
2005-05-04 by Varuzhan Danielyan
Attachments
- No local attachments were found for this message.