l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
September 2: Social Gathering
Next Installfest:
Sat. Sept. 27, 10am-6pm [Tentative]
Latest News:
Aug. 19: Siafoo slides and photos online
Page last updated:
2002 Apr 02 14:47
Events
 Meetings
 Installfests
 Demos
 Photos
Services
 Library
 LERT
 Jobs
 Documents
Interact
 Mailing Lists
 - Search
 - Archives
 Chat
About Us
 Members
 Projects
 Testimonials
 Call for Speakers
 Why Not MS?
 Finances
 Sponsors

^Home
?Search
?News & RSS
?Calendar
@Contact Us
$Buy Stuff
=Printable


The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] random number in C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] random number in C



On Tue, Apr 02, 2002 at 10:05:34AM -0800, Peter Jay Salzman wrote:
> i wrote some monte carlo code which obtains a random generator seed
> through a read to /dev/random.
> 
> on a lark, i did a run:
> 
> 	T: 4.0e+00  beta: 2.500e-01  trials: 1000000
> 	N: 10  M: 10  seed: 208006379

What code did you use to read from /dev/random(provide source)?  
What exact call did you call with rand() (provide source)?  
How exactly did you initialize the random number generator (provide source)?

You did pass the seed to srand() and not rand() right?

> the seed for these two runs is the same.  i would've expected that calls
> to rand() should've generated the same set of random numbers.  yet the
> different runs of the monte carlo code yield different results, which is
> fine, except i was expecting it to be exactly the same since the seed is
> the same.

A reasonable expectation.

If you port to any other platform you should use random and srandom
which provides for higher quality implemtnations on most platforms
(besides linux).   It also allows you to set a more complex seed.

-- 
Bill Broadley
Mathematics/Institute of Theoretical Dynamics
UC Davis
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

CD Burns Wanted!

LUGOD: Linux Users' Group of Davis
1105 Kennedy Place, Suite 1, Davis, CA 95616
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Marc Hall
For a generous donation to allow us to continue meeting at the Davis Library.