LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-05-2006, 04:54 PM   #1
firefly2442
Member
 
Registered: Apr 2003
Location: USA
Distribution: Ubuntu
Posts: 95

Rep: Reputation: 15
Statistics and Programming Question, generating a random number


In writing a computer program, I need to generate a random number. The problem is, it isn't a random number that is linear like between 1 and 100 for example. The number needs to follow a bell curve or normal distribution. A bell curve looks kind of like a bell where the line is highest in the middle and goes down on each side. I know about Z scores and have formulas for computing these values and so on but I'm not sure how to actually generate the random number. Basically, the random number needs to be generated off the normal distribution so that the majority of the random numbers are going to be pretty close to the middle. Anyone have any ideas on how to do this? Thanks in advance.
 
Old 01-05-2006, 05:10 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Well you need to generate you number and then pass them into a function that would simulate the bell curve so an input of 1-180 and the cosine (?) with a multiplier might give you an approximation of what you want.

graeme.
 
Old 01-06-2006, 04:33 PM   #3
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
This is pretty big topic. There's no built in solution - even generating good random numbers with uniform distribution is non-trivial.

You may want to look at the book Numerical Recipies in C.
Check out this site: http://www.bearcave.com/misl/misl_te...st/random.html as well.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
generating random numbers in C abk4523 Programming 20 01-10-2011 04:08 PM
code for generating random samples! aru_04 Programming 2 07-21-2005 08:35 AM
Generating Gaussian Random Numbers R00ts Programming 2 08-10-2004 11:51 PM
Generating random numbers for C program J-Stew Programming 14 02-06-2004 04:49 AM
I need random number in C ... purpleburple Programming 4 10-28-2002 04:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration