From: Frederick Joseph Ross <fjr6b@galileo.phys.virginia.edu>
To: Przemyslaw Sliwa <przemyslaw.sliwa@db.com>
Cc: gsl-discuss@sources.redhat.com
Subject: Re: Random Number Seed
Date: Mon, 01 Mar 2004 16:53:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.44.0403011106260.4082-100000@node3.galileo> (raw)
In-Reply-To: <OF1F9225D9.DD46CA3A-ON80256E4A.00387696@db.com>
The function you're after (at least on POSIX systems) is time in time.h
(try man 2 time if you're on a Linux or BSD machine). I nearly always
seed my generator this way at the start of a program. For instance,
#include <gsl/gsl_rng.h>
#include <time.h>
int main(int argc, char *argv[])
{
const gsl_rng_type *T = gsl_rng_mt19937;
gsl_rng *r = gsl_rng_alloc(T);
gsl_rng_set(r, (unsigned long) time(NULL))
...
}
Hope this helps.
Fred Ross
High Energy Physics Laboratory
University of Virginia
> Hi,
>
> I have a question:
> When one wants to use the random number seed different than the default one (equals to 0) one can use the macro GSL_RNG_SEED=seed from the command line. I would like to use the system time as the seed and have no idea how one can use the it from the command line. Therefore I want to use the function clock() in my C program. Could you help me how the seed can be initialized from the function claock() within my c program?
>
> Thank you for help,
>
> Pshem
>
>
>
>
> --------------------------------------------------
> Deutsche Bank AG
> Risk Controlling
> Credit Risk Engineering & Implementation
> / Daily Credit Risk
>
> Tel.: (+44 20) 754 59676 London
> Fax: (+44 20) 754 71060 London
>
> ----------------------------------------------------
>
>
> --
>
> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
>
next prev parent reply other threads:[~2004-03-01 16:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-01 16:03 Przemyslaw Sliwa
2004-03-01 16:53 ` Frederick Joseph Ross [this message]
2004-03-01 17:55 ` Robert G. Brown
2004-03-01 20:06 ` Daniel T Konkle
2005-02-21 11:55 ` Olaf Lenz
2005-02-21 12:03 ` Jerome BENOIT
2005-02-21 12:47 ` Robert G. Brown
2005-02-22 8:19 ` Olaf Lenz
2004-03-04 17:42 ` Brian Gough
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.44.0403011106260.4082-100000@node3.galileo \
--to=fjr6b@galileo.phys.virginia.edu \
--cc=gsl-discuss@sources.redhat.com \
--cc=przemyslaw.sliwa@db.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).