•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 456,472 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,777 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 4549 | Replies: 8
![]() |
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
I am new to programming in C and I'm trying to write a random number generator with a Gaussian distribution with user-defined mean and variance. I've looked at the code given in "Numerical Recipes in C" but I don't understand it very well. If anyone could point me in the direction of a tutorial or any other help it would be greatly appreciated.
What didn't you understand. Try a google search. Here is alink and a sample program:
http://www.taygeta.com/random/gaussian.html
http://www.physics.unlv.edu/~pang/comp2/code213.c
http://www.taygeta.com/random/gaussian.html
http://www.physics.unlv.edu/~pang/comp2/code213.c
>I get undefined refrecence errors relating to 'main' and the log and sqrt functions. I'm not
>sure why I'm getting these. I am using gcc in Linux.
I'll make an educated guess and say that you didn't link with the math library:
>sure why I'm getting these. I am using gcc in Linux.
I'll make an educated guess and say that you didn't link with the math library:
$ gcc main.c -lm $ ./a.out
I'm here to prove you wrong.
•
•
•
•
I have included math.h. I ran into the same problem when using acos to define pi in another program. When I replaced acos with atan it compiled and worked correctly.
Strange?
#include <stdio.h>
#include <math.h>
#include <string.h>
int main ( void )
{
float t = acos( 0.3 );
printf( "%f",t );
return 0;
}output
thwee@thwee-desktop:~$ gcc -Wall pedantic.c -lm thwee@thwee-desktop:~$ ./a.out 1.266104
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Random number generator's (C++)
- Realy weird random number generator bug (C++)
- Random number generator (Java)
- Random number generator (Java)
- Random number generator (Java)
- random number generator (C++)
- Help with random number gen (C++)
Other Threads in the C Forum
- Previous Thread: Download Turbo C
- Next Thread: Config File



Linear Mode