- #define N 100000
- #include <stdio.h>
- #include <strings.h>
- #include <stdlib.h>
- #include <math.h>
- //
- // random numbers in { 0 - 1 }
- //
- double random_num()
- {
- }
- //
- // Gaussian distributed random numbers
- //
- double Gaussian ( double *gauss1, double *gauss2 )
- {
- double twou, radius, theta;
- theta = 2*M_PI*random_num();
- }
- int main()
- {
- int i, j, count, counter[100];
- double deltav, gauss1, gauss2;
- deltav = 0.1;
- for ( j=0; j<100 ; j++ )
- counter[j] = 0;
- count = 0;
- for ( i=0; i<N ; i++ )
- {
- Gaussian( &gauss1, &gauss2 );
- j = (int)( (gauss1+5.0)/deltav );
- counter[j]++;
- j = (int)( (gauss2+5.0)/deltav );
- counter[j]++;
- count++;
- }
- count = 0;
- for ( j=0; j<100 ; j++ )
- {
- count = count + counter[j];
- }
- }
Raw Paste