473,786 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 23 '05 #1
5 16573
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.

Jul 23 '05 #2
Yudan YI (OSU) wrote:
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:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
<http://www.contendix.c om> - Software Development & Consulting

Jul 23 '05 #3
Hi,

Is there any other links to random number generator?

ko*****@w-manager.com

Jul 23 '05 #4
On 23 Feb 2005 22:55:40 -0800, "James Rafter" <jj******@yahoo .com>
wrote:
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
Jul 23 '05 #5
hautrub wrote:
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:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
<http://www.contendix.c om> - Software Development & Consulting

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
2175
by: Levi Campbell | last post by:
Hi, I'm working on a random number generator using the internet as a way to gather entropy, I have two questions. 1. is there a way to capture the internet stream? 2. how would I skip every 2nd, 3rd, or 4th byte to protect privacy?
2
2317
by: MLH | last post by:
This question, I apologize, is more of a math question than it is an Access question - I'm almost certain. The bell curve is another name for the normal distribution, which is a common type of graph that has more or less the shape of a bell. "The Bell Curve" was also the title of a book, a controversial book back in 1994. It was about intelligence. If you graph scores on an IQ test on the horizontal axis, and number of people who got...
70
6287
by: Ben Pfaff | last post by:
One issue that comes up fairly often around here is the poor quality of the pseudo-random number generators supplied with many C implementations. As a result, we have to recommend things like using the high-order bits returned by rand() instead of the low-order bits, avoiding using rand() for anything that wants decently random numbers, not using rand() if you want more than approx. UINT_MAX total different sequences, and so on. So I...
21
3025
by: Marc Dansereau | last post by:
Hi all I am new to this forum and to the c programming language. If I understand, the random() function in C return numbers that follow a uniform distribution U(0,1). Can somebody know how to generate a set of random number that follow a normal distribution N(0,1) ? I am develloping on power4 machine running AIX. Thank you for your help
13
3618
by: Jon Agiato | last post by:
Hello, I am sure this problem is easy to spot but I have been at this project all day and the frustration has finally overcome me. I am using this function in order to produce a standard normal distribution random number generator and then using the function in another part of my program in order to use the value. This function is called for many iterations. The problem is, through each run I am getting the exact same number generated...
14
9907
by: Anthony Liu | last post by:
I am at my wit's end. I want to generate a certain number of random numbers. This is easy, I can repeatedly do uniform(0, 1) for example. But, I want the random numbers just generated sum up to 1 . I am not sure how to do this. Any idea? Thanks.
9
9956
by: MyInfoStation | last post by:
Hi all, I am a newbie to Python and would like to genereate some numbers according to geometric distribution. However, the Python Random package seems do not have implemented functionality. I am wondering is there exist any other libraries that can do this job? Thanks a lot, Da
4
2546
by: fAnSKyer | last post by:
When using random we can get a uniform data sample. But how to transfer this sample in to a Guassion Sample? Thanks? Did C or C++ provide any function to do this? Thanks a lot. Cheers. fAnS.
4
2430
by: fAnSKyer | last post by:
When using random we can get a uniform data sample. But how to transfer this sample in to a Guassion Sample? Thanks? Did C or C++ provide any function to do this? Thanks a lot. Cheers. fAnS.
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9491
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.