 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Yudan YI (OSU) Guest
|
Posted: Thu Feb 24, 2005 4:52 am Post subject: how to generate random data for a normal distribution |
|
|
I want to generate random data from a normal distribution, while I checked
the functions, and I found rand(), which returns a pseudorandom integer
between zero and RAND_MAX. I am not sure how to use this function to
generate my random data from a normal distribution.
Thanks
Yudan
|
|
| Back to top |
|
 |
James Rafter Guest
|
Posted: Thu Feb 24, 2005 6:55 am Post subject: Re: how to generate random data for a normal distribution |
|
|
This is not really a C++ question. But...
Google 'Numerical Recipes'. There's a NR in C, C++, Fortran, etc. The
C one is available online.
but the C++ one is not.
Chapter 7 of the C book will show you what you need to do this from
scratch.
Perhaps others can recommend libraries if you don't want to do that.
|
|
| Back to top |
|
 |
Dietmar Kuehl Guest
|
Posted: Thu Feb 24, 2005 9:24 am Post subject: Re: how to generate random data for a normal distribution |
|
|
Yudan YI (OSU) wrote:
| Quote: | I want to generate random data from a normal distribution, while I
checked
the functions, and I found rand(), which returns a pseudorandom
integer
between zero and RAND_MAX. I am not sure how to use this function to
generate my random data from a normal distribution.
|
Have a look at the random number generator library at Boost
(<http://www.boost.org/>): this library supports several
distributions and the random number generators also have a
few other advantages of the typical standard library
implementations of 'rand()'. A library with essentially this
interface is also part of the standard library technical
report which includes candidates for future standard library
extensions.
--
<mailto:dietmar_kuehl (AT) yahoo (DOT) com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting
|
|
| Back to top |
|
 |
hautrub Guest
|
Posted: Thu Feb 24, 2005 6:57 pm Post subject: Re: how to generate random data for a normal distribution |
|
|
Hi,
Is there any other links to random number generator?
[email]kongyew (AT) w-manager (DOT) com[/email]
|
|
| Back to top |
|
 |
rossum Guest
|
Posted: Thu Feb 24, 2005 10:59 pm Post subject: Re: how to generate random data for a normal distribution |
|
|
On 23 Feb 2005 22:55:40 -0800, "James Rafter" <jjr2004a (AT) yahoo (DOT) com>
wrote:
| Quote: | This is not really a C++ question. But...
Google 'Numerical Recipes'. There's a NR in C, C++, Fortran, etc. The
C one is available online.
but the C++ one is not.
Chapter 7 of the C book will show you what you need to do this from
scratch.
Perhaps others can recommend libraries if you don't want to do that.
|
The C version is here:
http://www.library.cornell.edu/nr/cbookcpdf.html
Beware of the code style, it is a good example of the saying "A real
programmer can write FORTRAN in any language."
rossum
--
The ultimate truth is that there is no Ultimate Truth
|
|
| Back to top |
|
 |
Dietmar Kuehl Guest
|
Posted: Fri Feb 25, 2005 10:07 am Post subject: Re: how to generate random data for a normal distribution |
|
|
hautrub wrote:
| Quote: | Is there any other links to random number generator?
|
Probably but none that I'm immediately aware of without search
the Internet. Well, you can look at the technical report on
library extension at the standard C++ site but this is
essentially the Boost library in a different namespace and,
AFAIK, without a ready implementation.
However, out of curiosity: what desires in random number
generation leaves the Boost random number generator library
unsatisfied?
--
<mailto:dietmar_kuehl (AT) yahoo (DOT) com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|