[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] random number distributions
From: |
Peter Johansson |
Subject: |
Re: [Help-gsl] random number distributions |
Date: |
Mon, 29 Sep 2014 09:24:05 +1000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.8.0 |
On 09/27/2014 07:42 AM, Eric Smoll wrote:
Further comments are always welcome if anyone has any.
Hi Eric,
When I want non-deterministic behaviour I typically use /dev/urandom to
obtain a seed. I've pasted the code below in case you're interested.
unsigned char ulongsize=sizeof(unsigned long);
char* buffer=new char[ulongsize];
std::ifstream is("/dev/urandom", std::ios::binary);
is.read(buffer,ulongsize);
is.close();
unsigned long s=0;
memcpy(&s, buffer, ulongsize);
delete[] buffer;
rng->seed(s);
return s;
where 'rng' is a gsl_rng pointer.
Cheers,
--
Peter Johansson